public ActionResult CheckOut(FormCollection collection) { if (Session["Customer"] == null || Session["Customer"].ToString() == "") { return(RedirectToAction("Login", "Account")); } Order bill = new Order(); Customer customer = (Customer)Session["CustomerObject"]; List <Cart> orders = GetList(); bill.CtmID = customer.CtmID; bill.Odate = DateTime.Now; bill.DeliveryStatus = false; bill.PaymentCheck = false; db.Orders.Add(bill); db.SaveChanges(); foreach (var item in orders) { int id = item.TempID; Product product = db.Products.SingleOrDefault(n => n.PrID == id); OrderDetail orderDetail = new OrderDetail(); orderDetail.OrderID = bill.OrderID; orderDetail.PrID = item.TempID; orderDetail.Quantity = item.TempAmount; orderDetail.Total = (decimal)item.TempTotal; db.OrderDetails.Add(orderDetail); product.BeenBought = product.BeenBought + item.TempAmount; } db.SaveChanges(); Session["Cart"] = null; return(RedirectToAction("Confirm", "Cart")); }
public IActionResult SavePerscription(PercriptionViewModel per) { DateTime now = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (ModelState.IsValid && per.perscription.Patient_Id != 0) { per.perscription.DateCreate = now; per.perscription.DateModify = now; _context.Add(per.perscription); _context.SaveChanges(); } var p = _context.Perscriptions.Where(x => x.DateCreate == now).FirstOrDefault(); foreach (var item in per.perscriptionmedicinedetails) { var perr = new PerscriptionDetail(); perr.Medicine_Id = item.id; perr.Morning = item.sang; perr.Noon = item.trua; perr.Evening = item.toi; perr.Days = item.ngay; perr.Quantity = (perr.Morning + perr.Noon + perr.Evening) * perr.Days; perr.Perscription_Id = p.Id; _context.Add(perr); _context.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult PostBed([FromBody] Bed bed) { if (bed == null) { return(BadRequest()); } BedMatressDB.Beds.Add(bed); BedMatressDB.SaveChanges(); return(CreatedAtRoute("GetBed", new { id = bed.ID }, bed)); }
public IActionResult PostPictures([FromBody] Picture picture) { if (picture == null) { return(BadRequest()); } Console.Write(picture.Image); BedMatressDB.Pictures.Add(picture); BedMatressDB.SaveChanges(); return(CreatedAtRoute("GetOnePicture", new { id = picture.ID }, picture)); }
//http://localhost:61541/SqlServerUseGeometry/CreatePoint?cityName=%E5%8C%97%E4%BA%AC&x=100&y=10 public IActionResult CreatePoint(string cityName, double x, double y) { IPoint currentLocation = GetLocation(x, y); _dbContext.Cities.Add(new City() { CityName = cityName, Location = currentLocation }); _dbContext.SaveChanges(); return(Json("ok")); }
public IActionResult NewInsurance(VictimNewInsuranceViewModel vm) { if (ModelState.IsValid) { _context.Insurances.Add(vm.Insurance); _context.SaveChanges(); return(RedirectToAction("ReciveInsurance")); } else { return(View(vm)); } }
public bool Update(Topic entity) { try { var topic = db.Topics.Find(entity.ID); topic.Name = entity.Name; db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public IActionResult CreateRole() { try { string roleName = HttpContext.Request.Form["RoleName"]; _db.Roles.Add(new IdentityRole() { Name = roleName, NormalizedName = roleName.ToUpper() }); _db.SaveChanges(); ViewBag.ResultMessage = "Role created successfully!"; return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Create(Medicine medicine, int?Id) { if (Id == null) { if (ModelState.IsValid) { _context.Add(medicine); _context.SaveChanges(); return(RedirectToAction("Index")); } } else { if (ModelState.IsValid) { _context.Update(medicine); _context.SaveChanges(); return(RedirectToAction("Index")); } } return(View(medicine)); }
public ActionResult Signup(FormCollection collection, Customer customer) { var username = collection.Get("UserName"); var passwords = collection.Get("Passwords"); var name = collection.Get("CtmName"); var bday = String.Format("{0:MM/dd/yyyy }", collection.Get("Bdate")); var address = collection.Get("Addr"); var tell = collection.Get("Tell"); var email = collection.Get("Eaddr"); customer.UserName = username; customer.Passwords = passwords; customer.CtmName = name; customer.BDate = DateTime.Parse(bday); customer.Addr = address; customer.Tell = tell; customer.Eaddr = email; db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public long Insert(CourseCategory entity) { db.CourseCategories.Add(entity); db.SaveChanges(); return(entity.ID); }
public IActionResult Newsletter(NewsletterMember member) { _db.NewsletterMembers.Add(member); _db.SaveChanges(); return(RedirectToAction("Registered")); }
public long Insert(Role entity) { db.Roles.Add(entity); db.SaveChanges(); return(entity.ID); }
public long Insert(User entity) { db.Users.Add(entity); db.SaveChanges(); return(entity.ID); }