Ejemplo n.º 1
0
        public Int32 UpdateStoreItemCategory(StoreItemCategoryObject storeItemCategory)
        {
            try
            {
                if (storeItemCategory == null)
                {
                    return(-2);
                }

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

                var storeItemCategoryEntity = ModelCrossMapper.Map <StoreItemCategoryObject, StoreItemCategory>(storeItemCategory);
                if (storeItemCategoryEntity == null || storeItemCategoryEntity.StoreItemCategoryId < 1)
                {
                    return(-2);
                }
                _repository.Update(storeItemCategoryEntity);
                _uoWork.SaveChanges();
                return(5);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(-2);
            }
        }
Ejemplo n.º 2
0
 public long AddStoreItemCategory(StoreItemCategoryObject storeItemCategory)
 {
     try
     {
         if (storeItemCategory == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.Name.Trim().ToLower() == storeItemCategory.Name.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var storeItemCategoryEntity = ModelCrossMapper.Map <StoreItemCategoryObject, StoreItemCategory>(storeItemCategory);
         if (storeItemCategoryEntity == null || string.IsNullOrEmpty(storeItemCategoryEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeItemCategoryEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreItemCategoryId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Ejemplo n.º 3
0
        public ActionResult AddStoreItemCategory(StoreItemCategoryObject storeItemCategory)
        {
            var gVal = new GenericValidator();

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

                    var logoPath = SaveFile("");
                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        storeItemCategory.ImagePath = logoPath;
                    }

                    storeItemCategory.LastUpdated = DateTime.Now;

                    var k = new StoreItemCategoryServices().AddStoreItemCategory(storeItemCategory);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            gVal.Error = message_Feedback.Item_Duplicate;
                        }

                        if (k != -3 && k != -4)
                        {
                            gVal.Error = message_Feedback.Insertion_Failure;
                        }
                        gVal.Code = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    gVal.Code = 5;
                    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));
            }
        }
Ejemplo n.º 4
0
 public int UpdateStoreItemCategory(StoreItemCategoryObject storeItemCategory)
 {
     try
     {
         return(_storeItemCategoryRepository.UpdateStoreItemCategory(storeItemCategory));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Ejemplo n.º 5
0
        private GenericValidator ValidateStoreItemCategory(StoreItemCategoryObject storeItemCategory)
        {
            var gVal = new GenericValidator();

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

            gVal.Code = 5;
            return(gVal);
        }
Ejemplo n.º 6
0
        public ActionResult EditStoreItemCategory(StoreItemCategoryObject storeItemCategory)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreItemCategory = Session["_storeItemCategory"] as StoreItemCategoryObject;
                    if (oldStoreItemCategory == null || oldStoreItemCategory.StoreItemCategoryId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreItemCategory.Name = storeItemCategory.Name.Trim();

                    if (!string.IsNullOrEmpty(storeItemCategory.Description))
                    {
                        oldStoreItemCategory.Description = storeItemCategory.Description.Trim();
                    }

                    if (storeItemCategory.ParentCategoryId > 0)
                    {
                        oldStoreItemCategory.ParentCategoryId = storeItemCategory.ParentCategoryId;
                    }

                    var formerImagePath = string.Empty;
                    if (!string.IsNullOrEmpty(oldStoreItemCategory.ImagePath))
                    {
                        formerImagePath = oldStoreItemCategory.ImagePath;
                    }

                    var logoPath = SaveFile(formerImagePath);

                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        oldStoreItemCategory.ImagePath = logoPath;
                    }
                    oldStoreItemCategory.LastUpdated = DateTime.Now;
                    var k = new StoreItemCategoryServices().UpdateStoreItemCategory(oldStoreItemCategory);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            gVal.Error = message_Feedback.Item_Duplicate;
                        }

                        if (k != -3 && k != -4)
                        {
                            gVal.Error = message_Feedback.Update_Failure;
                        }
                        gVal.Code = -1;
                        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));
            }
        }