示例#1
0
        public string Delete(string Ma)
        {
            Accout dbEntry = context.Accouts.Find(Ma);

            if (dbEntry == null)
            {
                return(null);
            }
            context.Accouts.Remove(dbEntry);

            context.SaveChanges();
            return(Ma);
        }
示例#2
0
        //Thêm một đối tượng
        public string Insert(Accout model)
        {
            Accout dbEntry = context.Accouts.FirstOrDefault(user => user.UserName == model.UserName);

            if (dbEntry != null)
            {
                return(null);
            }

            context.Accouts.Add(model);
            context.SaveChanges();
            return(model.UserName);
        }
示例#3
0
        // Sửa dữ liệu
        public string Update(Accout model)
        {
            Accout dbEntry = context.Accouts.FirstOrDefault(user => user.UserName == model.UserName);

            //   LoaiBanDoc dbEntry = context.LoaiBanDocs.
            //  Where(x => x.LoaiBanDoc1 = model.LoaiBanDoc1).FirstOrDefault();
            if (dbEntry == null)
            {
                return(null);
            }
            dbEntry.UserName = model.UserName;
            dbEntry.Pass     = model.Pass;
            context.SaveChanges();

            return(model.UserName);
        }
示例#4
0
        public ActionResult ReturnAdmin(string UserName, string Pass)
        {
            F_Accout f_account = new F_Accout();

            if (f_account.FindEntity(UserName) == null)
            {
                ModelState.AddModelError("", "Thêm tài khoản thành công");
                Accout ac = new Accout();
                ac.UserName = UserName;
                ac.Pass     = Pass;
                f_account.Insert(ac);
            }
            else
            {
                ModelState.AddModelError("", "Tài khoản đã tồn tại");
            }
            return(View("ControlAdmin"));
        }
示例#5
0
        public ActionResult LoginResult(Accout ac)
        {
            MyDBContext context = new MyDBContext();

            if (ModelState.IsValid) //&& account.Pass.Contains(ac.Pass)
            {
                Accout account = context.Accouts.SingleOrDefault(user => user.UserName.Contains(ac.UserName));
                if (account != null && account.Pass.Contains(ac.Pass))
                {
                    var userSession = new UserID();
                    userSession.UserName = account.UserName;
                    Session.Add(Constant.UserSession, userSession);
                    return(RedirectToAction("Index", "Main"));
                }
                //return View("~/Areas/Admin/Views/Main/Index.cshtml");
            }
            return(View("Login"));
            //acount == null || ac.UserName.Contains(account.Pass)
        }
示例#6
0
    public async Task <bool> UnifiedCertification()
    {
        var        isOk                 = false;
        ISubSystem ISubSystemAccout     = new Accout(FirstName, LastName, Age, ValidAccout);
        ISubSystem ISubSystemAddress    = new Address(AddressDescription, City, State, ValidAddress);
        ISubSystem ISubSystemCreditCard = new CreditCard(CreditType, CardNumber, CardExpDate, ValidCard);

        if (
            (await ISubSystemAccout.IsValidAsync()) && (await ISubSystemAddress.IsValidAsync()) &&
            (await ISubSystemCreditCard.IsValidAsync())
            )
        {
            Console.WriteLine("认证成功");
            isOk = true;
        }
        else
        {
            Console.WriteLine("认证失败");
        }
        return(isOk);
    }
示例#7
0
    public async void CommonWayAsync()
    {
        Console.WriteLine("进入CommonWay方法...直接调用SubWay");
        string firstName = "张", lastName = "三丰", addressDescription = "武当", city = "十堰市", state = "中国", carditType = "掌门", cardExpDate = "9999-99-99";
        int    age = 100, cardNumber = 100;
        bool   validAccout = true, validAddress = true, validCard = true;

        ISubSystem ISubSystemAccout     = new Accout(firstName, lastName, age, validAccout);
        ISubSystem ISubSystemAddress    = new Address(addressDescription, city, state, validAddress);
        ISubSystem ISubSystemCreditCard = new CreditCard(carditType, cardNumber, cardExpDate, validCard);

        if (
            (await ISubSystemAccout.SaveAsync()) && (await ISubSystemAddress.SaveAsync()) &&
            (await ISubSystemCreditCard.SaveAsync())
            )
        {
            Console.WriteLine("CommonWay写入成功");
        }
        else
        {
            Console.WriteLine("CommonWay写入失败");
        }
    }
示例#8
0
        //Trả về một đối tượng khi biết khóa
        public Accout FindEntity(string Ma)
        {
            Accout dbEntry = context.Accouts.FirstOrDefault(user => user.UserName == Ma);

            return(dbEntry);
        }