public IHttpActionResult Puttiqclog(long id, tiqclog tiqclog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tiqclog.id) { return(BadRequest()); } db.Entry(tiqclog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tiqclogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult OrderProccess(FormCollection f) { List <CartItem> listcart = Session["CartSession"] as List <CartItem>; Hoa_Don bill = new Hoa_Don() { mahd = f["mahd"], ten_kh = f["customerName"], diachi = f["address"], ngaytao = DateTime.Now, trangthai = "Proccessing", }; db.Hoa_Don.Add(bill); db.SaveChanges(); foreach (CartItem cart in listcart) { SP_HD billDetail = new SP_HD() { mahd = bill.mahd, masp = cart.masp, sl = cart.sl, gia = cart.gia }; db.SP_HD.Add(billDetail); db.SaveChanges(); } Session.Remove(CartSession); return(View("OrderProccess")); }
public ActionResult Create([Bind(Include = "UserId,RoleId")] AspNetUserRoles aspNetUserRoles) { if (ModelState.IsValid) { db.AspNetUserRoles.Add(aspNetUserRoles); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aspNetUserRoles)); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { UserManager userManager = new UserManager(); if (userManager.CheckMail(model.Email) && userManager.CheckUserName(model.UserName)) { User user = new User(); user.Email = model.Email; user.UserName = model.UserName; user.Password = userManager.EncryptPassword(model.Password); user.sđt = model.sđt; user.diachi = model.diachi; db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("Register", "Username is existed"); return(View()); } } return(View()); }
public ActionResult Payment([Bind(Include = "CardNumber,NameOnCard,ExpiryDate")] CardDetails card) { if (ModelState.IsValid) { int userId = (int)Session["UserId"]; int?bookingId = db3.TicketBookings.Max(t => (int?)t.Id); if (bookingId == null) { bookingId = 1; } TransactionReference.Transaction trxn = new TransactionReference.Transaction { id = bookingId, quantity = (int)Session["TicketCount"], expDate = card.ExpiryDate, cardNo = card.CardNumber, nameOnCard = card.NameOnCard }; object ticketDay = Session["TicketDay"]; // Entry Fee: 10 CAD for weekdays and 12 CAD for weekends if (ticketDay != null && (((DateTime)ticketDay).DayOfWeek == DayOfWeek.Saturday || ((DateTime)ticketDay).DayOfWeek == DayOfWeek.Sunday)) { trxn.unitPrice = 12; } else { trxn.unitPrice = 10; } TransactionReference.TransactionWebserviceImplClient trxnClient = new TransactionReference.TransactionWebserviceImplClient(); trxnClient.Endpoint.Address = new EndpointAddress("http://dev.cs.smu.ca:9090/Assignment3/services/TransactionWebserviceImpl"); bool success = trxnClient.createTransaction(trxn); if (success) { TicketBooking ticketBooking = new TicketBooking { Id = (int)bookingId, BookedTicketDate = (DateTime)ticketDay, UserId = userId, SeatsCount = (int)Session["TicketCount"], TransactionId = (int)bookingId }; db3.TicketBookings.Add(ticketBooking); db3.SaveChanges(); //TransactionReference.Transaction transaction = trxnClient.getTransaction((int)bookingId); //SendEmailToCust(userId, transaction); SendEmailToCust(userId, trxn.id, trxn.unitPrice * trxn.quantity); Response.Write("<script>alert('Ticket/s Booked Successfully and Email Notification Sent!')</script>"); return(View("Payment")); } Response.Write("<script>alert('Unsuccessful Payment!')</script>"); return(View("Payment")); } return(View()); }
public long Insert(CategoryDetail entity) { db.CategoryDetail.Add(entity); db.SaveChanges(); return(entity.ID); }