Exemplo n.º 1
0
        public ActionResult add(AddAdminViewModel adminview)
        {
            if (adminbll.Exist(adminview.UserName))
            {
                ModelState.AddModelError("UserName", "名称已存在");
            }
            Admin _admin = new Admin()
            {
                LoginName = adminview.UserName,
                //默认用户组代码写这里
                TrueName    = adminview.TrueName,
                LoginPwd    = Utils.MD5(adminview.LoginPwd),
                AdminRoleID = adminview.RoleId,
                //用户状态问题
                Status     = 0,
                CreateTime = System.DateTime.Now
            };

            _admin = adminbll.Add(_admin);
            if (_admin.Id > 0)
            {
                return(RedirectToAction("list"));
            }
            else
            {
                return(RedirectToAction("add"));
            }
        }
Exemplo n.º 2
0
        private void ekleBtn_Click(object sender, EventArgs e)
        {
            if (id == -1)
            {
                var entity = _service.Add(new Admin
                {
                    Username = adTxt.Text.ToString(),
                    Userkey  = sifreTxt.Text.ToString()
                });


                if (entity != null)
                {
                    MessageBox.Show("Kayıt işlemi başarılı oldu.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Kayıt işlemi başarısız oldu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Temizle();
                BindData();
            }
            else
            {
                MessageBox.Show("Varolan veriyi tekrar ekleyemessiniz.Olası veri kaybını önlemek için temizle butonuna basabilirsiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public Admin2ViewModel Add(Admin2ViewModel obj)
        {
            var admin = Mapper.Map <Admin2ViewModel, Admin>(obj);

            BeginTransaction();
            _adminService.Add(admin);
            Commit();
            return(obj);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ID,UserName,PassWord")] Admin admin)
        {
            if (ModelState.IsValid)
            {
                await adminService.Add(admin);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(admin));
        }
        public IActionResult Add(Admin admin)
        {
            var result = _adminService.Add(admin);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public ActionResult Admins_Create([DataSourceRequest] DataSourceRequest request,
                                          global::StudentInternshipManagement.Models.Entities.Admin admin)
        {
            if (ModelState.IsValid)
            {
                _adminService.Add(admin);
            }

            return(Json(new[] { admin }.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 7
0
 public ActionResult Create(Admin admin)
 {
     try
     {
         adminService.Add(admin);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View(admin));
     }
 }
Exemplo n.º 8
0
        public ActionResult AdminRegister(RegisterAdminAndCompanyViewModel model)
        {
            ViewBag.Countries = _countryService.GetAll();
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Password != model.RePassword)
                    {
                        ViewBag.Message = "Şifreler uyuşmuyor";
                        return(View("AdminRegister"));
                    }
                    else
                    {
                        Company company = new Company();
                        company.About       = model.About;
                        company.CompanyName = model.CompanyName;
                        company.Freight     = model.Freight;
                        company.LogoPath    = model.LogoPath;
                        company.TaxNumber   = model.TaxNumber;
                        company.Phone       = model.Phone;
                        bool resultCompany = _companyService.Add(company);
                        if (!resultCompany)
                        {
                            ViewBag.Message = "Şirket eklemede hata meydana geldi!";
                        }

                        Admin admin = new Admin();
                        admin.AdminRole = _adminRoleService.GetAdminRoleByName("Company Admin");
                        admin.EMail     = model.EMail;
                        admin.Password  = model.Password;
                        admin.Username  = model.Username;
                        admin.Company   = company;
                        bool resultAdmin = _adminService.Add(admin);
                        if (!resultAdmin)
                        {
                            ViewBag.Message = "Şirket eklemede hata meydana geldi!";
                        }

                        return(RedirectToAction("AdminLogin", "Login"));
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View("AdminRegister"));
                }
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create([FromBody] Admin oUser)
        {
            try
            {
                await _adminService.Add(oUser);

                return(new OkObjectResult(oUser));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error" + ex.Message));
            }
        }
Exemplo n.º 10
0
        public async Task <HandleResult> Edit([FromBody] Administrator model)
        {
            var info = model.Id > 0 ? await _adminService.GetById(model.Id) : new Administrator();

            if (info == null)
            {
                return(HandleResult.Error("无效数据"));
            }

            info.Init();
            ReactForm.SetEditModelValue(info, model, info.Id > 0);

            return(info.Id > 0 ? await _adminService.Update(info) : await _adminService.Add(info));
        }
Exemplo n.º 11
0
        public void Register(string userName, string password)
        {
            byte[] userNameHash, passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(userName, password, out userNameHash, out passwordHash, out passwordSalt);
            var admin = new Admin
            {
                AdminUserName     = userNameHash,
                AdminPasswordHash = passwordHash,
                AdminPasswordSalt = passwordSalt,
                AdminRole         = "A"
            };

            _adminService.Add(admin);
        }
Exemplo n.º 12
0
        public void Register(string adminMail, string password)
        {
            byte[] userNameHash, passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(adminMail, password, out userNameHash, out passwordHash, out passwordSalt);
            var admin = new Admin
            {
                AdminUserName     = userNameHash,
                AdminPasswordHash = passwordHash,
                AdminPasswordSalt = passwordSalt,
                AdminYetkiID      = 1
            };

            _adminService.Add(admin);
        }
Exemplo n.º 13
0
        public IActionResult Register(AdminUser adminUser)
        {
            var returnModel = new ReturnModel();

            if (!ModelState.IsValid)
            {
                returnModel.IsSuccess = false;
                returnModel.Message   = "Formu Eksiksiz Doldurunuz";
                return(Ok(returnModel));
            }

            var uniqueUserName = _adminService.GetByUserName(adminUser.UserName);

            if (uniqueUserName != null)
            {
                returnModel.IsSuccess = false;
                returnModel.Message   = "Bu Kullanıcı Adı Sistemde Kayıtlı!";
                return(Ok(returnModel));
            }

            var admin = new AdminUser
            {
                FirstName       = adminUser.FirstName,
                LastName        = adminUser.LastName,
                Password        = adminUser.Password,
                ConfirmPassword = adminUser.ConfirmPassword,
                UserName        = adminUser.UserName,
                CreatedBy       = adminUser.UserName,
                CreatedDate     = DateTime.Now,
                UpdatedBy       = adminUser.UserName,
                UpdatedDate     = DateTime.Now,
                Role            = adminUser.Role
            };


            try
            {
                _adminService.Add(admin);
                returnModel.IsSuccess = true;
                returnModel.Message   = "Kayıt Başarılı";
            }
            catch (Exception ex)
            {
                returnModel.IsSuccess = false;
                returnModel.Message   = "Hata Oluştu" + ex.Message;
            }

            return(Ok(returnModel));
        }
Exemplo n.º 14
0
        public IDataResult <Admin> Register(RegisterDto registerDto)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(registerDto.Password, out passwordHash, out passwordSalt);

            var admin = new Admin
            {
                UserName     = registerDto.UserName,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt
            };

            _adminService.Add(admin);
            return(new SuccessDataResult <Admin>(admin, Messages.Registered));
        }
Exemplo n.º 15
0
        public IActionResult Register(AdministratorViewModel adminView)
        {
            var result = new Core.Entities.Concrete.Admin()
            {
                About    = adminView.About,
                Email    = adminView.Email,
                Lastname = adminView.LastName,
                Name     = adminView.FirstName,
                Username = adminView.Username,
                Password = adminView.Password
            };

            _adminService.Add(result);
            return(View());
        }
Exemplo n.º 16
0
        public void AdminRegister(string adminUserName, string adminMail, string password)
        {
            byte[] mailHash, passwordHash, passwordSalt;
            HashingHelper.AdminCreatePasswordHash(adminMail, password, out mailHash, out passwordHash, out passwordSalt);
            var admin = new Admin
            {
                AdminUserName     = adminUserName,
                AdminMail         = mailHash,
                AdminPasswordHash = passwordHash,
                AdminPasswordSalt = passwordSalt,
                AdminRole         = "A"
            };

            _adminService.Add(admin);
        }
Exemplo n.º 17
0
        public IDataResult <Admin> Register(AdminForRegisterDto adminForRegisterDto, string password)
        {
            var admin = new Admin
            {
                Email    = adminForRegisterDto.Email,
                Name     = adminForRegisterDto.FirstName,
                Lastname = adminForRegisterDto.LastName,
                Password = password,
                Username = adminForRegisterDto.UserName,
                About    = adminForRegisterDto.About
            };

            _adminService.Add(admin);
            return(new SuccessDataResult <Admin>(admin, Messages.AdminRegistered));
        }
Exemplo n.º 18
0
        public IActionResult CreateAdmin(Admin admin)
        {
            if (ModelState.IsValid)
            {
                var newAdmin = new Admin();
                newAdmin.Login    = admin.Login;
                newAdmin.Password = admin.Password;

                newAdmin = _adminService.Add(newAdmin);

                return(RedirectToAction(nameof(ListAdmin)));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <returns></returns>
 public ActionResult Add(WST.Model.Admin entity)
 {
     ModelState.Remove("ID");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("CreatedTime");
     ModelState.Remove("Type");
     if (ModelState.IsValid)
     {
         if (IAdminService.IsExits(x => x.Account == entity.Account))
         {
             return(JResult(Core.Code.ErrorCode.user_account_already_exist));
         }
         entity.Password    = CryptoHelper.MD5_Encrypt(entity.ConfirmPassword);
         entity.CreatedTime = entity.UpdatedTime = DateTime.Now;
         var result = IAdminService.Add(entity);
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }
 public ActionResult NewAdmin(Admin admin)
 {
     adminService.Add(admin);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 21
0
 public IActionResult Create(BlogAdminPageVM vm)
 {
     adminService.Add(vm);
     return(RedirectToAction("Blogs"));
 }
Exemplo n.º 22
0
 public async Task <bool> AddAdmin(AddAdminDto model)
 {
     return(await _service.Add(_mapping.Map <Admin>(model)));
 }