protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <DelPrizesDetailRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var PrizesDetailBLL = new C_PrizesDetailBLL(loggingSessionInfo); var ActivityBLL = new C_ActivityBLL(loggingSessionInfo); try { //删除 C_PrizesDetailEntity DelData = PrizesDetailBLL.GetByID(para.PrizesDetailID); if (DelData == null) { throw new APIException("奖品明细对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //执行 PrizesDetailBLL.Delete(DelData); if (ActivityBLL.IsActivityValid(para.ActivityID)) { var activity = ActivityBLL.GetByID(para.ActivityID); if (activity != null) { activity.Status = 0; } ActivityBLL.Update(activity); } } catch (APIException apiEx) { throw new APIException(apiEx.ErrorCode, apiEx.Message); } return(rd); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <GetActivityDeatilRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var ActivityBLL = new C_ActivityBLL(loggingSessionInfo); var ActivityMessageBLL = new C_ActivityMessageBLL(loggingSessionInfo); var ActivityTargetGroupBLL = new C_TargetGroupBLL(loggingSessionInfo); var ActivityPrizesBLL = new C_PrizesBLL(loggingSessionInfo); var ActivityPrizesDetailBLL = new C_PrizesDetailBLL(loggingSessionInfo); var ActivityRechargeStrategyBLL = new RechargeStrategyBLL(loggingSessionInfo); var pTran = ActivityBLL.GetTran(); using (pTran.Connection) { try { //删除 C_ActivityEntity DelData = ActivityBLL.GetByID(para.ActivityID); if (DelData == null) { throw new APIException("会员活动对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //执行 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "ActivityID", Value = para.ActivityID }); ActivityMessageBLL.Delete(ActivityMessageBLL.Query(complexCondition.ToArray(), null), pTran); ActivityTargetGroupBLL.Delete(ActivityTargetGroupBLL.Query(complexCondition.ToArray(), null), pTran); ActivityRechargeStrategyBLL.Delete(ActivityRechargeStrategyBLL.Query(complexCondition.ToArray(), null), pTran); var prize = ActivityPrizesBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); if (prize != null) { if (!string.IsNullOrWhiteSpace(prize.PrizesID.ToString())) { List <IWhereCondition> cCondition = new List <IWhereCondition> { }; cCondition.Add(new EqualsCondition() { FieldName = "PrizesID", Value = prize.PrizesID }); ActivityPrizesDetailBLL.Delete(ActivityPrizesDetailBLL.Query(cCondition.ToArray(), null), pTran); } ActivityPrizesBLL.Delete(ActivityPrizesBLL.Query(complexCondition.ToArray(), null), pTran); } ActivityBLL.Delete(DelData, pTran); pTran.Commit(); } catch (APIException apiEx) { pTran.Rollback(); throw new APIException(apiEx.ErrorCode, apiEx.Message); } } return(rd); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetPrizesRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var ActivityBLL = new C_ActivityBLL(loggingSessionInfo); var PrizesBLL = new C_PrizesBLL(loggingSessionInfo); var PrizesDetailBLL = new C_PrizesDetailBLL(loggingSessionInfo); var pTran = ActivityBLL.GetTran(); using (pTran.Connection) { try { if (string.IsNullOrWhiteSpace(para.ActivityID)) { throw new APIException("必须输入活动编号!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (string.IsNullOrWhiteSpace(para.PrizesID)) {//新增 C_PrizesEntity AddPrizesData = new C_PrizesEntity(); AddPrizesData.ActivityID = new Guid(para.ActivityID); AddPrizesData.PrizesType = para.PrizesType; AddPrizesData.PrizesName = para.PrizesDetailList.FirstOrDefault().CouponTypeName; AddPrizesData.CustomerID = loggingSessionInfo.ClientID; AddPrizesData.SendDate = DateTime.Now; List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "ActivityID", Value = para.ActivityID }); if (PrizesBLL.Query(complexCondition.ToArray(), null).ToList().Count > 0) { throw new APIException("不能重复创建奖品!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; PrizesBLL.Create(AddPrizesData); Guid?PrizesID = PrizesBLL.Query(complexCondition.ToArray(), null).ToList().FirstOrDefault().PrizesID; foreach (var itemes in para.PrizesDetailList) { C_PrizesDetailEntity AddDetailData = new C_PrizesDetailEntity(); AddDetailData.PrizesID = PrizesID; AddDetailData.CouponTypeID = new Guid(itemes.CouponTypeID); AddDetailData.CustomerID = loggingSessionInfo.ClientID; AddDetailData.NumLimit = itemes.NumLimit; AddDetailData.CouponTypeName = itemes.CouponTypeName; AddDetailData.CouponTypeDesc = itemes.CouponTypeDesc; PrizesDetailBLL.Create(AddDetailData, pTran); } } else {//编辑奖品明细 foreach (var itemes in para.PrizesDetailList) { C_PrizesDetailEntity AddDetailData = new C_PrizesDetailEntity(); AddDetailData.PrizesID = new Guid(para.PrizesID); AddDetailData.CouponTypeID = new Guid(itemes.CouponTypeID); AddDetailData.CustomerID = loggingSessionInfo.ClientID; AddDetailData.NumLimit = itemes.NumLimit; AddDetailData.CouponTypeName = itemes.CouponTypeName; AddDetailData.CouponTypeDesc = itemes.CouponTypeDesc; if (string.IsNullOrWhiteSpace(itemes.PrizesDetailID)) { PrizesDetailBLL.Create(AddDetailData, pTran); } else { AddDetailData.PrizesDetailID = new Guid(itemes.PrizesDetailID); if (itemes.IsEnable == 1) { PrizesDetailBLL.Update(AddDetailData, pTran); } else { PrizesDetailBLL.Delete(AddDetailData, pTran); } } } } pTran.Commit(); if (ActivityBLL.IsActivityValid(para.ActivityID)) { var activity = ActivityBLL.GetByID(para.ActivityID); if (activity != null) { activity.Status = 0; } ActivityBLL.Update(activity); } } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } } return(rd); }