public async Task <IActionResult> Create(AddServiceVM addServiceVM) { Service service = new Service(); FacSer_List facSer_List = new FacSer_List(); if (ModelState.IsValid) { service = addServiceVM.Service; _context.Add(service); await _context.SaveChangesAsync(); foreach (var item in addServiceVM.FFacilities) { if (item.Flag) { facSer_List.Fac_ID = item.Fac_ID; facSer_List.Service_ID = addServiceVM.Service.Service_ID; _context.Add(facSer_List); } } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(service)); }
public async Task <IActionResult> Confirm(string fullname, string gender, string id, string email, string birthday, string address, string phone) { string userid = Guid.NewGuid().ToString().Substring(0, 15); string userpass = Guid.NewGuid().ToString().Substring(0, 15); UserAcc useracc = new UserAcc { User_ID = userid, User_Pass = userpass, User_Role = 3 }; _context.Add(useracc); await _context.SaveChangesAsync(); Customer customer = new Customer { Cus_Address = address, Cus_Birth = DateTime.ParseExact(birthday, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture), Cus_Email = email, Cus_Gender = gender, Cus_ID = id, Cus_Name = fullname, Cus_Phone = phone, User_ID = userid }; var flag = await _context.Customer.Where(p => p.Cus_ID == id).CountAsync(); if ((int)flag > 0) { _context.Update(customer); } else { _context.Add(customer); } HttpContext.Session.SetString("cusName", fullname); HttpContext.Session.SetString("cusEmail", email); HttpContext.Session.SetString("cusPhone", phone); HttpContext.Session.SetString("cusAddress", address); double discount = 0; if (HttpContext.Session.GetInt32("Voucher") != null) { discount = (double)HttpContext.Session.GetInt32("Voucher"); } double grandtotal = (HttpContext.Session.GetInt32("GrandTotal") ?? 0); ViewBag.GrandTotal = (grandtotal * (double)((100 - discount) / 100)).ToString("C0", new CultureInfo("vi-vn")); ViewBag.VValue = discount; HttpContext.Session.SetString("CusID", customer.Cus_ID); await _context.SaveChangesAsync(); return(View(customer)); }
public async Task <IActionResult> Create([Bind("Fac_ID,Fac_Name,Fac_Address,Fac_Phone,Fac_Desc,Fac_Latitude,Fac_Longitude,Fac_Rating,Fac_Img")] Facility facility) { if (ModelState.IsValid) { _context.Add(facility); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(facility)); }
public async Task <IActionResult> Create([Bind("Feature_ID,Feature_Name,Feature_Icon")] Feature feature) { if (ModelState.IsValid) { _context.Add(feature); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(feature)); }
public async Task <IActionResult> Create([Bind("Cus_ID,User_ID,Cus_Name,Cus_Gender,Cus_Address,Cus_Email,Cus_Birth,Cus_Phone")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Create([Bind("RoomType_ID,RoomType_Name,RoomType_MaxCusNum,RoomType_Size,RoomType_Price,RoomType_Desc,RoomType_FTList")] RoomType roomType) { if (ModelState.IsValid) { _context.Add(roomType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(roomType)); }
public async Task <IActionResult> Forward(int?id) { if (id == null) { return(NotFound()); } var bill = await _context.Bill.FindAsync(id); bill.Bill_Status = 2; _context.Update(bill); _context.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(RoomVM roomVM) { Room room = new Room(); if (ModelState.IsValid) { room = roomVM.Room; _context.Add(room); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(room)); }