Ejemplo n.º 1
0
        public Int32 UpdateStoreItemVariation(StoreItemVariationObject productVariation)
        {
            try
            {
                if (productVariation == null)
                {
                    return(-2);
                }

                if (_repository.Count(m => m.VariationProperty.Trim().ToLower() == productVariation.VariationProperty.Trim().ToLower() && (m.StoreItemVariationId != productVariation.StoreItemVariationId)) > 0)
                {
                    return(-3);
                }

                var productVariationEntity = ModelCrossMapper.Map <StoreItemVariationObject, StoreItemVariation>(productVariation);
                if (productVariationEntity == null || productVariationEntity.StoreItemVariationId < 1)
                {
                    return(-2);
                }
                _repository.Update(productVariationEntity);
                _uoWork.SaveChanges();
                return(5);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(-2);
            }
        }
Ejemplo n.º 2
0
 public long AddStoreItemVariation(StoreItemVariationObject productVariation)
 {
     try
     {
         if (productVariation == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.VariationProperty.Trim().ToLower() == productVariation.VariationProperty.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var productVariationEntity = ModelCrossMapper.Map <StoreItemVariationObject, StoreItemVariation>(productVariation);
         if (productVariationEntity == null || string.IsNullOrEmpty(productVariationEntity.VariationProperty))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(productVariationEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreItemVariationId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Ejemplo n.º 3
0
 public int UpdateStoreItemVariation(StoreItemVariationObject storeItemVariation)
 {
     try
     {
         return(_storeItemVariationRepository.UpdateStoreItemVariation(storeItemVariation));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
        public ActionResult EditStoreItemVariation(StoreItemVariationObject productVariation)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreItemVariation = Session["_productVariation"] as StoreItemVariationObject;
                    if (oldStoreItemVariation == null || oldStoreItemVariation.StoreItemVariationId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldStoreItemVariation.VariationProperty = productVariation.VariationProperty.Trim();
                    var k = new StoreItemVariationServices().UpdateStoreItemVariation(oldStoreItemVariation);
                    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));
            }
        }
        private GenericValidator ValidateStoreItemVariation(StoreItemVariationObject productVariation)
        {
            var gVal = new GenericValidator();

            if (productVariation == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(productVariation.VariationProperty))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Product_Variation_Name_Error;
                return(gVal);
            }

            gVal.Code = 5;
            return(gVal);
        }
        public ActionResult AddStoreItemVariation(StoreItemVariationObject productVariation)
        {
            var gVal = new GenericValidator();

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

                    var k = new StoreItemVariationServices().AddStoreItemVariation(productVariation);
                    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));
            }
        }