public IHttpActionResult Create(TableModel model) { using (var scope = _contextScopeFactory.CreateReadOnly()) { var table = _tableService.Add(model); return(Ok(table)); } }
public IActionResult Create(string tableName) { if (!string.IsNullOrEmpty(tableName)) { ActionMessage response = tableService.Add(tableName); return(RedirectToAction("ActionMessage", "Message", response)); } return(View()); }
public async Task <IActionResult> Post([FromBody] TableRequestModel tableRequest) { var tableToAdd = await _tableService.Add(tableRequest.numberOfSeats); if (!tableToAdd.Success) { return(BadRequest()); } return(Ok(tableToAdd)); }
public ActionResult Add(Table table) { //Gọi service Add tableService.Add(table); //Save tableService.Save(); //Gọi service GetByID của grouptable lấy thông tin của group var resultGroupTable = groupTableService.GetSingleById(table.GroupTableID); var data = new { ID = table.ID, Name = table.Name, GroupTableName = resultGroupTable.Name, GroupTableID = resultGroupTable.ID, OrderCount = 0, Des = table.Description }; return(Json(data, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage Create(HttpRequestMessage request, Table table) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var result = tableService.Add(table); tableService.SaveChanges(); SaveHistory("Add new table with ID: " + result.ID); response = request.CreateResponse(HttpStatusCode.Created, result); } return response; })); }
public HttpResponseMessage Post(HttpRequestMessage request, TableViewModel tableViewModel) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { Table newTable = new Table(); newTable.UpdateTable(tableViewModel); var table = _tableService.Add(newTable); _tableService.SaveChange(); response = request.CreateResponse(HttpStatusCode.Created, table); } return response; })); }
public void AddTable(Database database, string name) { _tableService.Add(database: database, tableName: name); }