public UpdateVendorCoverageViewModel GetVendorCoverageForUpdateById(int VendorCoverageRowID) { try { UpdateVendorCoverageViewModel model = new UpdateVendorCoverageViewModel(); var entity = db.MasterVendorCoverages.Find(VendorCoverageRowID); if (entity != null) { model.VendorCoverageRowID = entity.VendorCoverageRowID; model.VendorRowID = entity.VendorRowID; model.CheckFamilyRowID = entity.CheckFamilyRowID; model.CountryRowID = entity.CountryRowID; model.StateRowID = entity.StateRowID; model.VendorCost = entity.VendorCost; model.AdditionalCosting = entity.AdditionalCosting; model.AdditionalCost = entity.AdditionalCost; model.Level1TAT = entity.Level1TAT; model.Level2TAT = entity.Level2TAT; model.Remarks = entity.Remarks; model.Status = entity.Status; } else { throw new Exception("Invalid Id!"); } return(model); } catch (Exception) { throw; } }
public void UpdateVendorCoverage(UpdateVendorCoverageViewModel model) { try { if (model != null && model.VendorRowID > 0) { MasterVendorCoverage entity = new MasterVendorCoverage(); entity.VendorCoverageRowID = model.VendorCoverageRowID; entity.VendorRowID = model.VendorRowID; entity.CheckFamilyRowID = model.CheckFamilyRowID; entity.CountryRowID = model.CountryRowID; entity.StateRowID = model.StateRowID; entity.VendorCost = model.VendorCost; entity.AdditionalCosting = model.AdditionalCosting; entity.AdditionalCost = model.AdditionalCost; entity.Level1TAT = model.Level1TAT; entity.Level2TAT = model.Level2TAT; entity.Remarks = model.Remarks; db.Entry(entity).State = EntityState.Modified; } else { throw new Exception("Vendor coverage details could not be blank!"); } } catch (Exception) { throw; } }