public ActionResult DeleteOrder(int id) { using (var ctx = new HamerimDbContext()) { ctx.Orders.Remove(ctx.Orders.Find(id)); ctx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult EditCategory(int id, string title) { using (var ctx = new HamerimDbContext()) { ctx.ServiceCategories.Find(id).Title = title; ctx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult EditService(int id, string title, int cost, int category) { using (var ctx = new HamerimDbContext()) { Service service = ctx.Services.Find(id); service.Title = title; service.Cost = cost; service.Category = ctx.ServiceCategories.Find(category); ctx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult AddCategory(string title) { using (var ctx = new HamerimDbContext()) { ctx.ServiceCategories.Add(new ServiceCategory() { Title = title }); ctx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult AddService(string title, int cost, int category) { using (var ctx = new HamerimDbContext()) { ctx.Services.Add(new Service() { Title = title, Cost = cost, Category = ctx.ServiceCategories.Find(category) }); ctx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult EditClub(int id, string name, int cost, string city, string street, int houseNumber = 0) { using (var ctx = new HamerimDbContext()) { Club club = ctx.Clubs.Find(id); club.Name = name; club.Cost = cost; club.Address.City = city; club.Address.Street = street; club.Address.HouseNumber = houseNumber; ctx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult BookOrder(int clubId, string clientName, string clientPhone, string txtDateTime, List <int> serviceIds) { using (HamerimDbContext ctx = new HamerimDbContext()) { Order newOrder = new Order { Date = DateTime.ParseExact(txtDateTime, "MM/dd/yyyy", null), Club = ctx.Clubs.Find(clubId), ClientName = clientName, ClientPhone = clientPhone, ServicesInOrder = serviceIds != null?serviceIds.Select(id => ctx.Services.Find(id)).ToList() : null }; ctx.Orders.Add(newOrder); ctx.SaveChanges(); return(RedirectToAction("FinishedOrder", new { orderNumber = newOrder.Id })); } }
public ActionResult AddClub(string name, int cost, string city, string street, int houseNumber = 0) { using (var ctx = new HamerimDbContext()) { ctx.Clubs.Add(new Club() { Name = name, Cost = cost, Address = new ClubAddress() { City = city, Street = street, HouseNumber = houseNumber } }); ctx.SaveChanges(); } return(RedirectToAction("Index")); }