예제 #1
0
 public int UpdateBillingCycle(BillingCycleObject billingCycle)
 {
     try
     {
         if (billingCycle == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(billingCycle.Name.Trim().ToLower()) || m.Code.Equals(billingCycle.Code) && (m.BillingCycleId != billingCycle.BillingCycleId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var billingCycleEntity = ModelCrossMapper.Map <BillingCycleObject, BillingCycle>(billingCycle);
         if (billingCycleEntity == null || billingCycleEntity.BillingCycleId < 1)
         {
             return(-2);
         }
         _repository.Update(billingCycleEntity);
         _uoWork.SaveChanges();
         return(5);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
예제 #2
0
 public long AddBillingCycle(BillingCycleObject billingCycle)
 {
     try
     {
         if (billingCycle == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(billingCycle.Name.Trim().ToLower()) || m.Code.Equals(billingCycle.Code));
         if (duplicates > 0)
         {
             return(-3);
         }
         var billingCycleEntity = ModelCrossMapper.Map <BillingCycleObject, BillingCycle>(billingCycle);
         if (billingCycleEntity == null || string.IsNullOrEmpty(billingCycleEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(billingCycleEntity);
         _uoWork.SaveChanges();
         return(returnStatus.BillingCycleId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
예제 #3
0
        private GenericValidator ValidateBillingCycle(BillingCycleObject billingCycle)
        {
            var gVal = new GenericValidator();

            if (billingCycle == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(billingCycle.Name))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Billing_Cycle_Name_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(billingCycle.Code))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Billing_Cycle_Code_Error;
                return(gVal);
            }
            if (billingCycle.Duration < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Billing_Cycle_Duration_Error;
                return(gVal);
            }
            gVal.Code = 5;
            return(gVal);
        }
예제 #4
0
        public ActionResult EditBillingCycle(BillingCycleObject billingCycle)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateBillingCycle(billingCycle);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_billingCycle"] == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldBillingCycle = Session["_billingCycle"] as BillingCycleObject;
                    if (oldBillingCycle == null || oldBillingCycle.BillingCycleId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldBillingCycle.Name     = billingCycle.Name.Trim();
                    oldBillingCycle.Code     = billingCycle.Code.Trim();
                    oldBillingCycle.Duration = billingCycle.Duration;
                    if (string.IsNullOrEmpty(billingCycle.Remark))
                    {
                        oldBillingCycle.Remark = billingCycle.Remark;
                    }
                    var k = new BillingCycleServices().UpdateBillingCycle(oldBillingCycle);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Update_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
 public int UpdateBillingCycle(BillingCycleObject billingCycleAccount)
 {
     try
     {
         return(_billingCycleAccountRepository.UpdateBillingCycle(billingCycleAccount));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
예제 #6
0
        public ActionResult AddBillingCycle(BillingCycleObject billingCycle)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateBillingCycle(billingCycle);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = 0;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var k = new BillingCycleServices().AddBillingCycle(billingCycle);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Insertion_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 0;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }