public IHttpActionResult Post(CurrencyCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = new CurrencyService(); if (!service.CreateCurrency(model)) { return(InternalServerError()); } return(Ok()); }
public bool CreateCurrency(CurrencyCreate model) { var entity = new Currency() { CurrencyName = model.CurrencyName, CurrencyNameLong = model.CurrencyNameLong }; using (var ctx = new ApplicationDbContext()) { ctx .Currencies .Add(entity); return(ctx.SaveChanges() == 1); } }