private GenericValidator ValidateStoreCity(StoreCityObject city) { var gVal = new GenericValidator(); if (city == null) { gVal.Code = -1; gVal.Error = message_Feedback.Fatal_Error; return(gVal); } if (string.IsNullOrEmpty(city.Name)) { gVal.Code = -1; gVal.Error = message_Feedback.City_Name_Error; return(gVal); } if (city.StoreStateId < 1) { gVal.Code = -1; gVal.Error = message_Feedback.State_Selection_Error; return(gVal); } gVal.Code = 5; return(gVal); }
public int UpdateStoreCity(StoreCityObject city) { try { if (city == null) { return(-2); } var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(city.Name.Trim().ToLower()) && city.StoreStateId.Equals(m.StoreStateId) && (m.StoreCityId != city.StoreCityId)); if (duplicates > 0) { return(-3); } var cityEntity = ModelCrossMapper.Map <StoreCityObject, StoreCity>(city); if (cityEntity == null || cityEntity.StoreCityId < 1) { return(-2); } _repository.Update(cityEntity); _uoWork.SaveChanges(); return(5); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(-2); } }
public long AddStoreCity(StoreCityObject city) { try { if (city == null) { return(-2); } var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(city.Name.Trim().ToLower()) && city.StoreStateId.Equals(m.StoreStateId)); if (duplicates > 0) { return(-3); } var cityEntity = ModelCrossMapper.Map <StoreCityObject, StoreCity>(city); if (cityEntity == null || string.IsNullOrEmpty(cityEntity.Name)) { return(-2); } var returnStatus = _repository.Add(cityEntity); _uoWork.SaveChanges(); return(returnStatus.StoreCityId); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(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)); } }
public int UpdateStoreCity(StoreCityObject city) { try { return(_cityRepository.UpdateStoreCity(city)); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(-2); } }
public long AddStoreCity(StoreCityObject cityAccount) { try { return(_cityRepository.AddStoreCity(cityAccount)); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(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)); } }