Ejemplo n.º 1
0
 public Int32 UpdateStoreOutlet(StoreOutletObject storeOutlet)
 {
     try
     {
         if (storeOutlet == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.OutletName.Trim().ToLower() == storeOutlet.OutletName.Trim().ToLower() && m.StoreOutletId != storeOutlet.StoreOutletId) > 0)
         {
             return(-3);
         }
         var storeOutletEntity = ModelCrossMapper.Map <StoreOutletObject, StoreOutlet>(storeOutlet);
         if (storeOutletEntity == null || storeOutletEntity.StoreOutletId < 1)
         {
             return(-2);
         }
         _repository.Update(storeOutletEntity);
         _uoWork.SaveChanges();
         return(5);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Ejemplo n.º 2
0
 public long AddStoreOutlet(StoreOutletObject storeOutlet)
 {
     try
     {
         if (storeOutlet == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.OutletName.Trim().ToLower() == storeOutlet.OutletName.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var storeOutletEntity = ModelCrossMapper.Map <StoreOutletObject, StoreOutlet>(storeOutlet);
         if (storeOutletEntity == null || storeOutletEntity.StoreAddressId < 1)
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storeOutletEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreOutletId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Ejemplo n.º 3
0
        private GenericValidator ValidateStoreOutlet(StoreOutletObject storeOutlet)
        {
            var gVal = new GenericValidator();

            if (storeOutlet == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }

            if (string.IsNullOrEmpty(storeOutlet.OutletName))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Outlet_Name_Eror;
                return(gVal);
            }

            if (storeOutlet.StoreAddressObject.StoreCityId < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.City_Selection_Error;
                return(gVal);
            }

            if (string.IsNullOrEmpty(storeOutlet.StoreAddressObject.StreetNo))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Outlet_Address_Not_Provided;
                return(gVal);
            }

            gVal.Code = 5;
            return(gVal);
        }
Ejemplo n.º 4
0
        public ActionResult AddStoreOutlet(StoreOutletObject storeOutlet)
        {
            var gVal = new GenericValidator();

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

                    var storeAddress = new StoreAddressObject
                    {
                        StoreCityId = storeOutlet.StoreAddressObject.StoreCityId,
                        StreetNo    = storeOutlet.StoreAddressObject.StreetNo
                    };
                    var t = new StoreAddressServices().AddStoreAddress(storeAddress);
                    if (t < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Outlet_Address_Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    storeOutlet.StoreAddressId = t;
                    storeOutlet.DateCreated    = DateTime.Now;
                    var k = new StoreOutletServices().AddStoreOutlet(storeOutlet);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    gVal.Code  = 5;
                    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  = 0;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 5
0
 public int UpdateStoreOutlet(StoreOutletObject storeOutlet)
 {
     try
     {
         return(_storeOutletRepository.UpdateStoreOutlet(storeOutlet));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Ejemplo n.º 6
0
        public ActionResult EditStoreOutlet(StoreOutletObject storeOutlet)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreOutlet = Session["_storeOutlet"] as StoreOutletObject;
                    if (oldStoreOutlet == null || oldStoreOutlet.StoreOutletId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreOutlet.OutletName     = storeOutlet.OutletName;
                    oldStoreOutlet.DefaultTax     = storeOutlet.DefaultTax;
                    oldStoreOutlet.FacebookHandle = storeOutlet.FacebookHandle;

                    var storeAddress = new StoreAddressObject
                    {
                        StoreCityId    = storeOutlet.StoreAddressObject.StoreCityId,
                        StreetNo       = storeOutlet.StoreAddressObject.StreetNo,
                        StoreAddressId = oldStoreOutlet.StoreAddressId
                    };

                    var t = new StoreAddressServices().UpdateStoreAddress(storeAddress);
                    if (t < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Outlet_Address_Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreOutlet.IsOperational = storeOutlet.IsOperational;
                    if (!string.IsNullOrEmpty(oldStoreOutlet.FacebookHandle))
                    {
                        oldStoreOutlet.FacebookHandle = storeOutlet.FacebookHandle;
                    }

                    if (!string.IsNullOrEmpty(oldStoreOutlet.TwitterHandle))
                    {
                        oldStoreOutlet.TwitterHandle = storeOutlet.TwitterHandle;
                    }

                    var k = new StoreOutletServices().UpdateStoreOutlet(oldStoreOutlet);
                    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;
                    gVal.Error = message_Feedback.Update_Success;
                    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));
            }
        }