public HttpResponseMessage UpdateTable(int id, [FromBody] RestaurantTable tables) { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { try { var entity = entities.RestaurantTable.FirstOrDefault(e => e.Id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Tables not found")); } else { entity.TableName = tables.TableName; entity.TableSeatNumber = tables.TableSeatNumber; entity.TableBooking = tables.TableBooking; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public HttpResponseMessage UpdateItems(int id, [FromBody] RestaurantItems items) { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { try { var entity = entities.RestaurantItems.FirstOrDefault(e => e.Id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Tables not found")); } else { entity.ItemCategory = items.ItemCategory; entity.ItemName = items.ItemName; entity.ItemPrice = items.ItemPrice; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public HttpResponseMessage DeleteItems(int id) { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { var entity = entities.RestaurantItems.FirstOrDefault(e => e.Id == id); entities.RestaurantItems.Remove(entity); entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } }
public HttpResponseMessage DeleteTableOrder(string tablename) { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { entities.CustomerService.RemoveRange(entities.CustomerService.Where(e => e.TableName == tablename)); entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } }
public HttpResponseMessage DeleteOrder(string mail, string tablename, string itemname, int itemprice) { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { var item = entities.CustomerService.FirstOrDefault(s => s.RestaurantMail == mail && s.TableName == tablename && s.ItemName == itemname && s.ItemPrice == itemprice); entities.CustomerService.Remove(item); entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } }
public HttpResponseMessage Post(RestaurantProcess process) { try { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { entities.RestaurantProcess.Add(process); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, process); message.Headers.Location = new Uri(Request.RequestUri + process.Id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public IHttpActionResult Register(RestaurantAccounts model) { GlobalDesignEntities db = new GlobalDesignEntities(); db.RestaurantAccounts.Add(new RestaurantAccounts() { RestaurantName = model.RestaurantName, RestaurantMail = model.RestaurantMail, RestaurantPassword = model.RestaurantPassword, ConfirmPassword = model.ConfirmPassword, RestaurantPhone = model.RestaurantPhone, RestaurantAdress = model.RestaurantAdress, RestaurantCity = model.RestaurantCity, RestaurantDistrict = model.RestaurantDistrict }); db.SaveChanges(); return(Ok()); }
public HttpResponseMessage Post([FromBody] TableIncome tableIncome) { try { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { entities.TableIncome.Add(tableIncome); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, tableIncome); message.Headers.Location = new Uri(Request.RequestUri + tableIncome.Id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage PostCustomerReservation([FromBody] CustomerOldBooking oldBooking) { try { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { entities.CustomerOldBooking.Add(oldBooking); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, oldBooking); message.Headers.Location = new Uri(Request.RequestUri + oldBooking.Id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Post(RestaurantItems items) { try { GlobalDesignEntities db = new GlobalDesignEntities(); db.RestaurantItems.Add(new RestaurantItems() { RestaurantMail = items.RestaurantMail, ItemCategory = items.ItemCategory, ItemName = items.ItemName, ItemPrice = items.ItemPrice }); db.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, items); message.Headers.Location = new Uri(Request.RequestUri + items.Id.ToString()); return(message); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Post(RestaurantTable tables) { try { GlobalDesignEntities db = new GlobalDesignEntities(); db.RestaurantTable.Add(new RestaurantTable() { Id = tables.Id, RestaurantMail = tables.RestaurantMail, TableName = tables.TableName, TableSeatNumber = tables.TableSeatNumber, TableBooking = tables.TableBooking }); db.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, tables); message.Headers.Location = new Uri(Request.RequestUri + tables.Id.ToString()); return(message); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage UpdateCusTable(string tablename, string resname, RestaurantTable tables) { using (GlobalDesignEntities entities = new GlobalDesignEntities()) { try { var entity = entities.RestaurantTable.FirstOrDefault(e => e.TableName == tablename && e.RestaurantMail == resname); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Tables not found")); } else { entity.TableBooking = tables.TableBooking; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }