|
|
@ -28,6 +28,24 @@ namespace EasyBL.WEBAPP.WSM |
|
|
|
|
|
|
|
#endregion 預訂維護(單筆查詢 call BookingMaintainQryService QueryOne)
|
|
|
|
|
|
|
|
public ResponseMessage SaveBooking(SETB_SAL_Booking Booking) { |
|
|
|
|
|
|
|
ResponseMessage rsResult = null; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(Booking.BookingID)) |
|
|
|
{ |
|
|
|
// insert
|
|
|
|
rsResult = Insert(Booking); |
|
|
|
} |
|
|
|
else { |
|
|
|
// update
|
|
|
|
rsResult = Update(Booking); |
|
|
|
} |
|
|
|
|
|
|
|
return rsResult; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#region 預訂維護(新增)
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -36,7 +54,7 @@ namespace EasyBL.WEBAPP.WSM |
|
|
|
/// <param name="i_crm">todo: describe i_crm parameter on UpdImportCustomers</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// Origtek framwork API
|
|
|
|
public ResponseMessage Insert(RequestMessage i_crm) |
|
|
|
public ResponseMessage Insert(SETB_SAL_Booking Booking) |
|
|
|
{ |
|
|
|
ResponseMessage rm = null; |
|
|
|
string sMsg = null; |
|
|
@ -49,27 +67,12 @@ namespace EasyBL.WEBAPP.WSM |
|
|
|
|
|
|
|
var sBookingID = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
var oEntity = _fetchEntity<View_SAL_Booking>(i_crm) as SETB_SAL_Booking; |
|
|
|
|
|
|
|
_setEntityBase(oEntity, i_crm); |
|
|
|
oEntity.BookingID = sBookingID; |
|
|
|
oEntity.DelStatus = "N"; |
|
|
|
|
|
|
|
|
|
|
|
BookingMaintain_QryService bm_qry = new BookingMaintain_QryService(); |
|
|
|
|
|
|
|
var iOldCout = bm_qry.QueryIntCount(i_crm); |
|
|
|
|
|
|
|
if (oEntity.OrderByValue <= iOldCout) |
|
|
|
{ |
|
|
|
var iRelUp = db.Updateable<SETB_SAL_Booking>() |
|
|
|
.UpdateColumns(x => new SETB_SAL_Booking { OrderByValue = x.OrderByValue + 1 }) |
|
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.BookingID == oEntity.BookingID && x.OrderByValue >= oEntity.OrderByValue) |
|
|
|
.ExecuteCommand(); |
|
|
|
} |
|
|
|
Booking.BookingID = sBookingID; |
|
|
|
Booking.DelStatus = "N"; |
|
|
|
Booking.Effective = "Y"; |
|
|
|
|
|
|
|
var iRel = db.Insertable(oEntity).ExecuteCommand(); |
|
|
|
rm = new SuccessResponseMessage(null, i_crm); |
|
|
|
var iRel = db.Insertable(Booking).ExecuteCommand(); |
|
|
|
rm = new SuccessResponseMessage(null, null); |
|
|
|
rm.DATA.Add(BLWording.REL, iRel); |
|
|
|
} while (false); |
|
|
|
|
|
|
@ -79,13 +82,12 @@ namespace EasyBL.WEBAPP.WSM |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
sMsg = Util.GetLastExceptionMsg(ex); |
|
|
|
LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(BookingMaintain_UpdService), "", "Insert 預訂維護(新增)", "", "", ""); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
if (null != sMsg) |
|
|
|
{ |
|
|
|
rm = new ErrorResponseMessage(sMsg, i_crm); |
|
|
|
rm = new ErrorResponseMessage(sMsg, null); |
|
|
|
} |
|
|
|
} |
|
|
|
return rm; |
|
|
@ -101,7 +103,7 @@ namespace EasyBL.WEBAPP.WSM |
|
|
|
/// <param name="i_crm">todo: describe i_crm parameter on UpdImportCustomers</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// Origtek framwork API
|
|
|
|
public ResponseMessage Update(RequestMessage i_crm) |
|
|
|
public ResponseMessage Update(SETB_SAL_Booking Booking) |
|
|
|
{ |
|
|
|
ResponseMessage rm = null; |
|
|
|
string sMsg = null; |
|
|
@ -111,34 +113,14 @@ namespace EasyBL.WEBAPP.WSM |
|
|
|
{ |
|
|
|
do |
|
|
|
{ |
|
|
|
|
|
|
|
var oNewEntity = _fetchEntity<View_SAL_Booking>(i_crm) as SETB_SAL_Booking; |
|
|
|
|
|
|
|
_setEntityBase(oNewEntity, i_crm); |
|
|
|
oNewEntity.DelStatus = "N"; |
|
|
|
|
|
|
|
var oOldEntity = db.Queryable<SETB_SAL_Booking>().Single(x => x.OrgID == i_crm.ORIGID && x.BookingID == oNewEntity.BookingID); |
|
|
|
|
|
|
|
if (oNewEntity.OrderByValue > oOldEntity.OrderByValue) |
|
|
|
{ |
|
|
|
var iRelUp = db.Updateable<SETB_SAL_Booking>() |
|
|
|
.UpdateColumns(x => new SETB_SAL_Booking { OrderByValue = x.OrderByValue - 1 }) |
|
|
|
.Where(x => x.OrgID == oNewEntity.OrgID && x.BookingID == oNewEntity.BookingID && x.OrderByValue <= oNewEntity.OrderByValue && x.OrderByValue > oOldEntity.OrderByValue).ExecuteCommand(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var iRelDown = db.Updateable<SETB_SAL_Booking>() |
|
|
|
.UpdateColumns(x => new SETB_SAL_Booking { OrderByValue = x.OrderByValue + 1 }) |
|
|
|
.Where(x => x.OrgID == oNewEntity.OrgID && x.BookingID == oNewEntity.BookingID && x.OrderByValue >= oNewEntity.OrderByValue && x.OrderByValue < oOldEntity.OrderByValue).ExecuteCommand(); |
|
|
|
} |
|
|
|
|
|
|
|
var iRel = db.Updateable(oNewEntity) |
|
|
|
|
|
|
|
var iRel = db.Updateable(Booking) |
|
|
|
.IgnoreColumns(x => new |
|
|
|
{ |
|
|
|
x.CreateUser, |
|
|
|
x.CreateDate |
|
|
|
}).ExecuteCommand(); |
|
|
|
rm = new SuccessResponseMessage(null, i_crm); |
|
|
|
rm = new SuccessResponseMessage(null, null); |
|
|
|
rm.DATA.Add(BLWording.REL, iRel); |
|
|
|
} while (false); |
|
|
|
|
|
|
@ -148,13 +130,12 @@ namespace EasyBL.WEBAPP.WSM |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
sMsg = Util.GetLastExceptionMsg(ex); |
|
|
|
LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(BookingMaintain_UpdService), "", "Update 預訂維護(修改)", "", "", ""); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
if (null != sMsg) |
|
|
|
{ |
|
|
|
rm = new ErrorResponseMessage(sMsg, i_crm); |
|
|
|
rm = new ErrorResponseMessage(sMsg, null); |
|
|
|
} |
|
|
|
} |
|
|
|
return rm; |
|
|
|
xxxxxxxxxx