public HttpResponseMessage PostAccount(NewAccountInputModel model) { if (_accountService.CreateAccount(model)) { return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public bool CreateAccount(NewAccountInputModel model) { try { var account = new Account() { Name = model.Name, Description = model.Description, StartDate = DateTime.Now, CreateDate = DateTime.Now, CreatedBy = Environment.UserName }; db.Accounts.Add(account); db.SaveChanges(); return(true); } catch (Exception e) { _loggingService.LogError(0, e.Message); return(false); } }