Ejemplo n.º 1
0
        public ActionResult DeleteCity(long id)
        {
            var gVal = new GenericValidator();

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Invalid_Selection;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var k = new StoreCityServices().DeleteStoreCity(id);
                if (k)
                {
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Delete_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Delete_Failure;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 5;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        public ActionResult EditCity(StoreCityObject city)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreCity(city);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = 0;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

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

                    var oldStoreCity = Session["_city"] as StoreCityObject;
                    if (oldStoreCity == null || oldStoreCity.StoreCityId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldStoreCity.Name         = city.Name.Trim();
                    oldStoreCity.StoreStateId = city.StoreStateId;
                    var k = new StoreCityServices().UpdateStoreCity(oldStoreCity);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        gVal.Code  = 0;
                        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.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 3
0
        public ActionResult GetCityObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <StoreCityObject> filteredStoreCityObjects;
                var countG = new StoreCityServices().GetObjectCount();

                var pagedStoreCityObjects = GetCities(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredStoreCityObjects = new StoreCityServices().Search(param.sSearch);
                }
                else
                {
                    filteredStoreCityObjects = pagedStoreCityObjects;
                }

                if (!filteredStoreCityObjects.Any())
                {
                    return(Json(new List <StoreCityObject>(), JsonRequestBehavior.AllowGet));
                }

                var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
                Func <StoreCityObject, string> orderingFunction = (c => sortColumnIndex == 1 ? c.Name : c.StateName
                                                                   );

                var sortDirection = Request["sSortDir_0"]; // asc or desc
                filteredStoreCityObjects = sortDirection == "asc" ? filteredStoreCityObjects.OrderBy(orderingFunction) : filteredStoreCityObjects.OrderByDescending(orderingFunction);

                var displayedUserProfilenels = filteredStoreCityObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.StoreCityId), c.Name, c.StateName };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredStoreCityObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <StoreCityObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 4
0
        public ActionResult AddCity(StoreCityObject city)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreCity(city);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = 0;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var k = new StoreCityServices().AddStoreCity(city);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Insertion_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));
            }
        }
Ejemplo n.º 5
0
        public ActionResult GetCity(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new StoreCityObject(), JsonRequestBehavior.AllowGet));
                }

                var city = new StoreCityServices().GetStoreCity(id);
                if (id < 1)
                {
                    return(Json(new StoreCityObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_city"] = city;
                return(Json(city, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new StoreCityObject(), JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 6
0
        public ActionResult GetCities()
        {
            var cities = new StoreCityServices().GetCities() ?? new List <StoreCityObject>();

            return(Json(cities, JsonRequestBehavior.AllowGet));
        }