public void Updateliquidator(Liquidator subject) { try { var db = new ApplicationDbContext(); var liquidator = db.Liquidators.Where(s => s.LiquidatorID == subject.LiquidatorID).SingleOrDefault(); liquidator.Name = subject.Name; liquidator.RegistryNumber = subject.RegistryNumber; liquidator.Email = subject.Email; liquidator.MobilePhoneNumber = subject.MobilePhoneNumber; db.SaveChanges(); ErrorLabel.Text = String.Empty; } catch (DbEntityValidationException ex) { ErrorLabel.Visible = true; ErrorLabel.Text = EventLogManager.LogError(ex); } catch (Exception exp) { ErrorLabel.Text = exp.Message; ErrorLabel.Visible = true; } }
public void InsertLiquidator() { var db = new ApplicationDbContext(); var liquidator = new Liquidator(); TryUpdateModel(liquidator); if (ModelState.IsValid) { try { db.Liquidators.Add(liquidator); db.SaveChanges(); ErrorLabel.Text = String.Empty; } catch (DbEntityValidationException ex) { ErrorLabel.Visible = true; ErrorLabel.Text = EventLogManager.LogError(ex); } catch (Exception exp) { ErrorLabel.Text = exp.Message; ErrorLabel.Visible = true; } } else { ErrorLabel.Text = "Complete todos los campos."; ErrorLabel.Visible = true; } }
public void DeleteLiquidator(Liquidator subject) { try { var db = new ApplicationDbContext(); var liquidator = db.Liquidators.Where(s => s.LiquidatorID == subject.LiquidatorID).SingleOrDefault(); db.Liquidators.Remove(liquidator); db.SaveChanges(); ErrorLabel.Text = String.Empty; } catch (DbEntityValidationException ex) { ErrorLabel.Visible = true; ErrorLabel.Text = EventLogManager.LogError(ex); } catch (Exception exp) { ErrorLabel.Text = exp.Message; ErrorLabel.Visible = true; } }