public UpdateAntecedentViewModel GetAntecedentForUpdateById(short AntecedentRowID) { try { UpdateAntecedentViewModel model = new UpdateAntecedentViewModel(); var entity = db.MasterAntecedents.Find(AntecedentRowID); if (entity != null) { model.AntecedentRowId = entity.AntecedentRowId; model.FieldName = entity.FieldName; model.DisplayName = entity.DisplayName; model.AntecedentTypeRowId = entity.AntecedentTypeRowId; model.CheckFamilyRowID = entity.CheckFamilyRowID; model.BGVPublished = entity.BGVPublished; model.ReportPublished = entity.ReportPublished; model.EmailAdded = entity.EmailAdded; model.Status = entity.Status; model.DisplayOrder = entity.DisplayOrder; } else { throw new Exception("Invalid Id"); } return(model); } catch (Exception) { throw; } }
public void UpdateAntecedent(UpdateAntecedentViewModel model) { try { if (model != null && model.AntecedentRowId > 0) { db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).FieldName = model.FieldName; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).DisplayName = model.DisplayName; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).AntecedentTypeRowId = model.AntecedentTypeRowId; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).CheckFamilyRowID = model.CheckFamilyRowID; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).BGVPublished = model.BGVPublished; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).ReportPublished = model.ReportPublished; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).EmailAdded = model.EmailAdded; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).Status = model.Status; db.MasterAntecedents.Single(b => b.AntecedentRowId == model.AntecedentRowId).DisplayOrder = Convert.ToByte(model.DisplayOrder); } else { throw new Exception("Antecedent could not be blank!"); } } catch (Exception) { throw; } }
public UpdateAntecedentPage(Antecedent antecedent) { InitializeComponent(); var viewModel = new UpdateAntecedentViewModel(); viewModel.Antecedent = antecedent; BindingContext = viewModel; }