public bool UpdateCurrency(CurrencyModel currencyModel) { Mapper.Initialize(cfg => { cfg.CreateMap <CurrencyModel, ExchangeRate>(); }); using (AirLineEntities entities = new AirLineEntities()) { ExchangeRate exchangeRate = (from c in entities.ExchangeRates where c.ID == currencyModel.ID select c).FirstOrDefault(); exchangeRate = Mapper.Map <CurrencyModel, ExchangeRate>(currencyModel); // int result = entities.SaveChanges(); // ExchangeRate exchangeRate = new ExchangeRate(); entities.Configuration.ValidateOnSaveEnabled = false; exchangeRate.ID = currencyModel.ID; entities.Entry(exchangeRate).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); entities.Configuration.ValidateOnSaveEnabled = true; int result = entities.SaveChanges(); if (result == 1) { return(true); } } return(false); }
public void setComfirm(int id) { Schedule schedule = context.Schedules.Find(id); schedule.Confirmed = !schedule.Confirmed; context.SaveChanges(); }
public bool DeleteCurrency(CurrencyModel currencyModel) { Mapper.Initialize(cfg => { cfg.CreateMap <CurrencyModel, ExchangeRate>(); }); using (AirLineEntities entities = new AirLineEntities()) { ExchangeRate exchangeRate = new ExchangeRate(); entities.Configuration.ValidateOnSaveEnabled = false; exchangeRate.ID = currencyModel.ID; entities.Entry(exchangeRate).State = System.Data.Entity.EntityState.Deleted; entities.SaveChanges(); entities.Configuration.ValidateOnSaveEnabled = true; int result = entities.SaveChanges(); return(true); } }
public bool SaveCurrency(CurrencyModel currencyModel) { Mapper.Initialize(cfg => { cfg.CreateMap <CurrencyModel, ExchangeRate>(); }); using (AirLineEntities entities = new AirLineEntities()) { ExchangeRate newRate = new ExchangeRate(); newRate = Mapper.Map <CurrencyModel, ExchangeRate>(currencyModel); entities.ExchangeRates.Add(newRate); int result = entities.SaveChanges(); if (result == 1) { return(true); } } return(false); }
public void setLogUser(Log log) { context.Logs.Add(log); context.SaveChanges(); }
public void addUser(User user) { context.Users.Add(user); context.SaveChanges(); }