Exemplo n.º 1
0
 public int UpdateStoreDepartment(StoreDepartmentObject storeDepartment)
 {
     try
     {
         if (storeDepartment == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == storeDepartment.Name.Trim().ToLower() && (m.StoreDepartmentId != storeDepartment.StoreDepartmentId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var storeDepartmentEntity = ModelCrossMapper.Map <StoreDepartmentObject, StoreDepartment>(storeDepartment);
         if (storeDepartmentEntity == null || storeDepartmentEntity.StoreDepartmentId < 1)
         {
             return(-2);
         }
         _repository.Update(storeDepartmentEntity);
         _uoWork.SaveChanges();
         return(5);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Exemplo n.º 2
0
 public long AddStoreDepartment(StoreDepartmentObject storeDepartment)
 {
     try
     {
         if (storeDepartment == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower() == storeDepartment.Name.Trim().ToLower());
         if (duplicates > 0)
         {
             return(-3);
         }
         var storeDepartmentEntity = ModelCrossMapper.Map <StoreDepartmentObject, StoreDepartment>(storeDepartment);
         if (storeDepartmentEntity == null || string.IsNullOrEmpty(storeDepartmentEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeDepartmentEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreDepartmentId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Exemplo n.º 3
0
        public ActionResult EditStoreDepartment(StoreDepartmentObject storeDepartment)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreDepartment = Session["_storeDepartment"] as StoreDepartmentObject;
                    if (oldStoreDepartment == null || oldStoreDepartment.StoreDepartmentId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldStoreDepartment.Name = storeDepartment.Name.Trim();
                    if (!string.IsNullOrEmpty(storeDepartment.Description))
                    {
                        oldStoreDepartment.Description = storeDepartment.Description.Trim();
                    }
                    var k = new StoreDepartmentServices().UpdateStoreDepartment(oldStoreDepartment);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code = 5;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                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));
            }
        }
Exemplo n.º 4
0
 public int UpdateStoreDepartment(StoreDepartmentObject storeDepartmentAccount)
 {
     try
     {
         return(_storeDepartmentAccountRepository.UpdateStoreDepartment(storeDepartmentAccount));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Exemplo n.º 5
0
        private GenericValidator ValidateStoreDepartment(StoreDepartmentObject storeDepartment)
        {
            var gVal = new GenericValidator();

            if (storeDepartment == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(storeDepartment.Name))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Delivery_Method_Title_Error;
                return(gVal);
            }

            gVal.Code = 5;
            return(gVal);
        }
Exemplo n.º 6
0
        public ActionResult AddStoreDepartment(StoreDepartmentObject storeDepartment)
        {
            var gVal = new GenericValidator();

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

                    var k = new StoreDepartmentServices().AddStoreDepartment(storeDepartment);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code = 5;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                gVal.Code  = -1;
                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));
            }
        }