コード例 #1
0
ファイル: CustomerService.cs プロジェクト: AleaxLizzy/Frame
 public bool AddOrUpdate(CustomerModel model)
 {
     if (model.Id > 0)
     {
         var entity = _customerRepository.Table.FirstOrDefault(x => x.Id == model.Id);
         entity.Name       = model.Name;
         entity.ModifyTime = DateTime.Now;
         entity.Active     = model.Active;
         return(_customerRepository.Update(entity) > 0);
     }
     else
     {
         var entity = new Customer
         {
             Name        = model.Name,
             Email       = model.Email,
             CreatedTime = DateTime.Now,
             Active      = model.Active,
             Type        = model.Type,
             ParentId    = model.ParentId,
             PassWord    = SignUtil.MD5Sign(model.PassWord)
         };
         return(_customerRepository.Insert(entity) > 0);
     }
 }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: AleaxLizzy/Frame
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                ErrorNotification("验证码错误");
                return(View());
            }
            var passWod  = SignUtil.MD5Sign(model.PassWord);
            var customer = _customerService.GetCustomer(model.Email, passWod);

            if (customer == null)
            {
                ErrorNotification("用户名或密码错误");
            }
            else
            {
                _workContext.CurrentCustomer = customer;
                if (!string.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }

                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
コード例 #3
0
ファイル: Configuration.cs プロジェクト: AleaxLizzy/Frame
        protected override void Seed(FrameDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //


            context.Set <Customer>().AddOrUpdate(
                p => p.Type,
                new Customer
            {
                Name        = "Admin",
                Email       = "*****@*****.**",
                PassWord    = SignUtil.MD5Sign("888888"),
                Active      = true,
                Type        = CustomerTypeEnum.SuperAdmin,
                CreatedTime = DateTime.Now,
                ParentId    = 0,
                Roles       = new List <Role>
                {
                    new Role
                    {
                        Name        = "³¬¼¶¹ÜÀíÔ±",
                        Active      = true,
                        ParentId    = 0,
                        Type        = RoleTypeEnum.SuperAdminRole,
                        CreatedTime = DateTime.Now,
                        SystemName  = "Admin_SuperRole"
                    }
                }
            }
                );
        }