public UpdateBranchOfficeViewModel GetBranchOfficeForUpdateById(short BORowID) { try { UpdateBranchOfficeViewModel model = new UpdateBranchOfficeViewModel(); var entity = db.MasterCompanyBranches.Find(BORowID); if (entity != null) { model.BORowID = entity.BORowID; model.BOName = entity.BOName; model.BOAddress = entity.BOAddress; model.BOConcernPersonName = entity.BOConcernPersonName; model.BOContactNumber = entity.BOContactNumber; model.BOEmailId = entity.BOEmailId; model.CompanyRowID = entity.CompanyRowID; model.Status = entity.Status; } else { throw new Exception("Invalid Id!"); } return(model); } catch (Exception) { throw; } }
public void UpdateBranchOffice(UpdateBranchOfficeViewModel model) { try { if (model != null && model.BORowID > 0) { db.MasterCompanyBranches.Single(b => b.BORowID == model.BORowID).BOName = model.BOName; db.MasterCompanyBranches.Single(b => b.BORowID == model.BORowID).BOAddress = model.BOAddress; db.MasterCompanyBranches.Single(b => b.BORowID == model.BORowID).BOConcernPersonName = model.BOConcernPersonName; db.MasterCompanyBranches.Single(b => b.BORowID == model.BORowID).BOContactNumber = model.BOContactNumber; db.MasterCompanyBranches.Single(b => b.BORowID == model.BORowID).BOEmailId = model.BOEmailId; } else { throw new Exception("Branch office could not be blank!"); } } catch (Exception) { throw; } }