コード例 #1
0
        public Int32 UpdateStoreItemType(StoreItemTypeObject productType)
        {
            try
            {
                if (productType == null)
                {
                    return(-2);
                }

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

                var productTypeEntity = ModelCrossMapper.Map <StoreItemTypeObject, StoreItemType>(productType);
                if (productTypeEntity == null || productTypeEntity.StoreItemTypeId < 1)
                {
                    return(-2);
                }
                _repository.Update(productTypeEntity);
                _uoWork.SaveChanges();
                return(5);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(-2);
            }
        }
コード例 #2
0
 public long AddStoreItemType(StoreItemTypeObject productType)
 {
     try
     {
         if (productType == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.Name.Trim().ToLower() == productType.Name.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var productTypeEntity = ModelCrossMapper.Map <StoreItemTypeObject, StoreItemType>(productType);
         if (productTypeEntity == null || string.IsNullOrEmpty(productTypeEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(productTypeEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreItemTypeId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
コード例 #3
0
        public ActionResult AddStoreItemType(StoreItemTypeObject productType)
        {
            var gVal = new GenericValidator();

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

                    var logoPath = SaveFile("");
                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        productType.SampleImagePath = logoPath;
                    }
                    var k = new StoreItemTypeServices().AddStoreItemType(productType);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            productType.Name = message_Feedback.Item_Duplicate;
                        }

                        if (k != -3 && k != -4)
                        {
                            productType.Name = message_Feedback.Insertion_Failure;
                        }
                        gVal.Code = -1;
                        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  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
 public int UpdateStoreItemType(StoreItemTypeObject storeItemType)
 {
     try
     {
         return(_storeItemTypeRepository.UpdateStoreItemType(storeItemType));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
コード例 #5
0
        private GenericValidator ValidateStoreItemType(StoreItemTypeObject productType)
        {
            var gVal = new GenericValidator();

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

            gVal.Code = 5;
            return(gVal);
        }
コード例 #6
0
        public ActionResult EditStoreItemType(StoreItemTypeObject productType)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreItemType = Session["_productType"] as StoreItemTypeObject;
                    if (oldStoreItemType == null || oldStoreItemType.StoreItemTypeId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreItemType.Name = productType.Name.Trim();

                    if (!string.IsNullOrEmpty(productType.Description))
                    {
                        oldStoreItemType.Description = productType.Description.Trim();
                    }

                    var formerSampleImagePath = string.Empty;
                    if (!string.IsNullOrEmpty(oldStoreItemType.SampleImagePath))
                    {
                        formerSampleImagePath = oldStoreItemType.SampleImagePath;
                    }

                    var logoPath = SaveFile(formerSampleImagePath);

                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        oldStoreItemType.SampleImagePath = logoPath;
                    }

                    var k = new StoreItemTypeServices().UpdateStoreItemType(oldStoreItemType);
                    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;
                    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));
            }
        }