public void Edit(USAStateModel uSAStateModel) { try { USAState uSAState = dbContext.USAStates.Where(x => x.Id == uSAStateModel.Id).FirstOrDefault(); if (uSAState == null) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Critical, null, Resources.NotFound); return; } if (Validate(uSAStateModel)) { return; } USAStateMapper.Map(dbContext, uSAStateModel, uSAState); base.SaveChanges(); uSAStateModel.AddSuccess(Resources.USAStateUpdatedSuccessfully, LookUps.SuccessType.Full); } catch (Exception ex) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Exception, ex); base.UndoUpdates(); } }
public void Delete(USAStateModel uSAStateModel) { try { if (ValidateDelete(uSAStateModel)) { return; } USAState uSAState = dbContext.USAStates.Where(x => x.Id == uSAStateModel.Id).FirstOrDefault(); if (uSAState == null) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Critical, null, Resources.NotFound); return; } dbContext.USAStates.Remove(uSAState); base.SaveChanges(); uSAStateModel.AddSuccess(Resources.USAStateDeletedSuccessfully, LookUps.SuccessType.Full); } catch (System.Data.Entity.Infrastructure.DbUpdateException) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Business, null, Resources.RefrenceDeleteError); base.UndoUpdates(); } catch (Exception ex) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Exception, ex); base.UndoUpdates(); } }
public static void Map(LMYFrameWorkMVCEntities dbContext, USAStateModel src, USAState dest) { if (src == null || dest == null) { return; } dest.CopyPropertyValues(src); }
public void PrepareUSAStateModel(USAStateModel uSAStateModel) { try { } catch (Exception ex) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Critical, ex); } }
public TruckLoadModel() { TruckModel = new TruckModel(false); DriverModel = new DriverModel(false); CompanyModel = new CompanyModel(false); StatusModel = new StatusModel(false); FromStateModel = new USAStateModel(false); ToStateModel = new USAStateModel(false); StatesList = new List <SelectListItem>(); StatusesList = new List <SelectListItem>(); }
public ActionResult Create(BaseModel baseModel) { USAStateModel uSAStateModel = new USAStateModel(); uSAStateModel.CopyBaseModel(baseModel); using (USAStateBAL uSAStateBAL = new USAStateBAL(ContextInfo)) { uSAStateBAL.PrepareUSAStateModel(uSAStateModel); } return(View("Create", uSAStateModel)); }
public ActionResult View(string id) { USAStateModel uSAStateModel = new USAStateModel(); uSAStateModel.Id = id; using (USAStateBAL uSAStateBAL = new USAStateBAL(ContextInfo)) { uSAStateBAL.GetUSAStateModel(uSAStateModel); // uSAStateBAL.PrepareUSAStateModel(uSAStateModel); } return(View(uSAStateModel)); }
public static void Map(LMYFrameWorkMVCEntities dbContext, List <USAState> src, List <USAStateModel> dest) { if (src == null || dest == null) { return; } foreach (USAState uSAState in src) { USAStateModel uSAStateModel = new USAStateModel(); Map(dbContext, uSAState, uSAStateModel); dest.Add(uSAStateModel); } }
private bool Validate(USAStateModel uSAStateModel) { if (dbContext.USAStates.Any(x => x.Name == uSAStateModel.Name && x.Id != uSAStateModel.Id.ToString())) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, uSAStateModel.GetDisplayName(x => x.Name)), uSAStateModel.nameof(x => x.Name)); } if (dbContext.USAStates.Any(x => x.StateCode.ToLower() == uSAStateModel.StateCode.ToLower() && x.Id != uSAStateModel.Id.ToString())) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, uSAStateModel.GetDisplayName(x => x.StateCode)), uSAStateModel.nameof(x => x.StateCode)); } return(uSAStateModel.HasErrorByType()); }
// GET: USAState/Edit/5 public ActionResult Edit(string id, BaseModel baseModel) { USAStateModel uSAStateModel = new USAStateModel(); uSAStateModel.CopyBaseModel(baseModel); uSAStateModel.Id = id; using (USAStateBAL uSAStateBAL = new USAStateBAL(ContextInfo)) { uSAStateBAL.GetUSAStateModel(uSAStateModel); uSAStateBAL.PrepareUSAStateModel(uSAStateModel); } return(View(uSAStateModel)); }
public ActionResult Delete(USAStateModel uSAStateModel) { using (USAStateBAL uSAStateBAL = new USAStateBAL(ContextInfo)) { uSAStateBAL.Delete(uSAStateModel); if (uSAStateModel.HasErrorByType()) { uSAStateBAL.GetUSAStateModel(uSAStateModel); // uSAStateBAL.PrepareUSAStateModel(uSAStateModel); } } return(View(uSAStateModel)); }
public void GetUSAStateModel(USAStateModel uSAStateModel) { try { USAState uSAState = dbContext.USAStates.Where(x => x.Id == uSAStateModel.Id).FirstOrDefault(); if (uSAState == null) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Critical, null, Resources.NotFound); } else { USAStateMapper.Map(dbContext, uSAState, uSAStateModel); } } catch (Exception ex) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Critical, ex); } }
public ActionResult Create(USAStateModel uSAStateModel) { using (USAStateBAL uSAStateBAL = new USAStateBAL(ContextInfo)) { if (ModelState.IsValid) { uSAStateBAL.Create(uSAStateModel); } if (uSAStateModel.HasErrorByType(LMYFrameWorkMVC.Common.LookUps.ErrorType.Critical) || uSAStateModel.HasSuccess(LMYFrameWorkMVC.Common.LookUps.SuccessType.Full)) { return(base.RedirectToActionWithData(new Dictionary <string, object> { { "baseModel", uSAStateModel } })); } uSAStateBAL.PrepareUSAStateModel(uSAStateModel); } return(View("Create", uSAStateModel)); }
public void Create(USAStateModel uSAStateModel) { try { if (Validate(uSAStateModel)) { return; } using (var transaction = dbContext.Database.BeginTransaction()) { try { USAState uSAState = new USAState(); USAStateMapper.Map(dbContext, uSAStateModel, uSAState); uSAState.Id = Guid.NewGuid().ToString(); dbContext.USAStates.Add(uSAState); base.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } uSAStateModel.AddSuccess(Resources.USAStateAddedSuccessfully, LookUps.SuccessType.Full); } } catch (Exception ex) { base.HandleError(uSAStateModel, CommonLayer.LookUps.ErrorType.Exception, ex); base.UndoUpdates(); } }
private bool ValidateDelete(USAStateModel uSAStateModel) { return(uSAStateModel.HasErrorByType()); }
// GET: USAState public ActionResult Index(USAStateModel returnedModel) { return(View(returnedModel)); }