Exemple #1
0
        public Int32 UpdateStoreItemBrand(StoreItemBrandObject storeItemBrand)
        {
            try
            {
                if (storeItemBrand == null)
                {
                    return(-2);
                }

                if (_repository.Count(m => m.Name.Trim().ToLower() == storeItemBrand.Name.Trim().ToLower() && (m.StoreItemBrandId != storeItemBrand.StoreItemBrandId)) > 0)
                {
                    return(-3);
                }

                var storeItemBrandEntity = ModelCrossMapper.Map <StoreItemBrandObject, StoreItemBrand>(storeItemBrand);
                if (storeItemBrandEntity == null || storeItemBrandEntity.StoreItemBrandId < 1)
                {
                    return(-2);
                }
                _repository.Update(storeItemBrandEntity);
                _uoWork.SaveChanges();
                return(5);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(-2);
            }
        }
Exemple #2
0
 public long AddStoreItemBrand(StoreItemBrandObject storeItemBrand)
 {
     try
     {
         if (storeItemBrand == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.Name.Trim().ToLower() == storeItemBrand.Name.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var storeItemBrandEntity = ModelCrossMapper.Map <StoreItemBrandObject, StoreItemBrand>(storeItemBrand);
         if (storeItemBrandEntity == null || string.IsNullOrEmpty(storeItemBrandEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeItemBrandEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreItemBrandId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Exemple #3
0
        public ActionResult EditStoreItemBrand(StoreItemBrandObject storeItemBrand)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreItemBrand = Session["_storeItemBrand"] as StoreItemBrandObject;
                    if (oldStoreItemBrand == null || oldStoreItemBrand.StoreItemBrandId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldStoreItemBrand.Name        = storeItemBrand.Name.Trim();
                    oldStoreItemBrand.LastUpdated = DateTime.Now;
                    if (!string.IsNullOrEmpty(storeItemBrand.Description))
                    {
                        oldStoreItemBrand.Description = storeItemBrand.Description.Trim();
                    }
                    var k = new StoreItemBrandServices().UpdateStoreItemBrand(oldStoreItemBrand);
                    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));
            }
        }
Exemple #4
0
 public int UpdateStoreItemBrand(StoreItemBrandObject storeItemBrand)
 {
     try
     {
         return(_storeItemBrandRepository.UpdateStoreItemBrand(storeItemBrand));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Exemple #5
0
        private GenericValidator ValidateStoreItemBrand(StoreItemBrandObject storeItemBrand)
        {
            var gVal = new GenericValidator();

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

            gVal.Code = 5;
            return(gVal);
        }
Exemple #6
0
        public ActionResult AddStoreItemBrand(StoreItemBrandObject storeItemBrand)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreItemBrand(storeItemBrand);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    storeItemBrand.LastUpdated = DateTime.Now;
                    var k = new StoreItemBrandServices().AddStoreItemBrand(storeItemBrand);
                    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));
            }
        }