public ActionResult DeleteConfirmed(int id)
        {
            CustomerInfomation customerInfomation = db.CustomerInfomations.Find(id);

            db.CustomerInfomations.Remove(customerInfomation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,FullName,BirthDay,Address,PhoneNumber,Email,UserName,Password,CompanyCode,CreatedBy,CreatedDate,ModifiedDate,ModifiedBy,IsActive,IsDelete")] CustomerInfomation customerInfomation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customerInfomation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customerInfomation));
 }
        // GET: Customer/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerInfomation customerInfomation = db.CustomerInfomations.Find(id);

            if (customerInfomation == null)
            {
                return(HttpNotFound());
            }
            return(View(customerInfomation));
        }
Exemple #4
0
        public static async Task CompleteOrder(ApplicationDbContext context, CustomerInfomation info, ApplicationUser user)
        {
            Orders order = new Orders()
            {
                OrderNumber        = GenerateCode.GenerateOrderNumber(),
                User               = user,
                CustomerInfomation = info
            };

            context.Entry(user).State = EntityState.Detached;
            await context.AddAsync(order);

            await context.SaveChangesAsync();
        }
        public async Task <IActionResult> CustomerInfo(CustomerInfomation info)
        {
            var uSearch = await _userManager.GetUserAsync(HttpContext.User);

            ApplicationUser user = new ApplicationUser()
            {
                Id       = uSearch.Id,
                Email    = uSearch.Email,
                UserName = uSearch.UserName
            };

            if (!ModelState.IsValid)
            {
                Console.WriteLine("Completed");
                await OrderDb.CompleteOrder(_context, info, user);

                CartHelper.ClearCookie(_accessor);
                return(RedirectToAction("Index", "Home"));
            }
            return(View(info));
        }