Ejemplo n.º 1
0
        public async Task <ActionResult> updatecomment(int id, string comment)
        {
            DonHang donhang = db.DonHang.SingleOrDefault(t => t.ID == id);

            if (donhang == null)
            {
                return(HttpNotFound());
            }

            donhang.Comment         = comment;
            db.Entry(donhang).State = System.Data.Entity.EntityState.Modified;
            await db.SaveChangesAsync();

            return(RedirectToAction("chitietdonhang", new { id = id }));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> deleteproduct(int id)
        {
            SanPham sp = db.SanPham.SingleOrDefault(t => t.ID == id);

            if (sp == null)
            {
                return(HttpNotFound());
            }

            sp.TinhTrang       = "DISABLE";
            db.Entry(sp).State = System.Data.Entity.EntityState.Modified;
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.UserName
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    ProjectS3Entities db        = new ProjectS3Entities();
                    AspNetUsers       userinfor = db.AspNetUsers.SingleOrDefault(t => t.Id == user.Id);

                    userinfor.HoTen       = model.HoTen;
                    userinfor.SoDienThoai = model.SoDienThoai;
                    userinfor.DiaChi      = model.DiaChi;
                    userinfor.avatar      = model.avatar;

                    db.AspNetUsers.Add(userinfor);
                    db.Entry(userinfor).State = System.Data.Entity.EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task setValue(string key, string value)
        {
            MyDynamicvalue info = db.MyDynamicvalue.SingleOrDefault(t => t.Key == key);

            // If dont have the key, add new key
            if (info == null)
            {
                info       = new MyDynamicvalue();
                info.Key   = key;
                info.value = value;
                db.MyDynamicvalue.Add(info);
                await db.SaveChangesAsync();
            }
            else
            {
                // set new value for key
                info.value           = value;
                db.Entry(info).State = System.Data.Entity.EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> updateUserInfor(string hoten, string linkavatar, string sodienthoai, string diachi)
        {
            ProjectS3Entities db     = new ProjectS3Entities();
            string            userid = User.Identity.GetUserId();
            AspNetUsers       user   = db.AspNetUsers.SingleOrDefault(t => t.Id == userid);

            user.HoTen       = hoten;
            user.avatar      = linkavatar;
            user.SoDienThoai = sodienthoai;
            user.DiaChi      = diachi;

            db.Entry(user).State = System.Data.Entity.EntityState.Modified;
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }