示例#1
0
        public IActionResult CreateManager([FromBody] ManagerDto managerDto)
        {
            if (managerDto is null)
            {
                return(BadRequest(ModelState));
            }

            if (!_managerRepo.ManagerExists(managerDto.Mail))
            {
                ModelState.AddModelError("", $"A manager already exists with mail {managerDto.Mail}");
                return(StatusCode(404, ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var managerObj = _mapper.Map <Manager>(managerDto);

            if (!_managerRepo.CreateManager(managerObj))
            {
                ModelState.AddModelError("", $"Something wrong happened when adding manager {managerObj.Mail}");
            }
            return(Ok(managerObj));
        }
示例#2
0
        public ActionResult CreateManager(ManagerViewModel managerViewModel)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Sector Error");

                return(View());
            }


            _managerRepository.CreateManager(managerViewModel);


            return(View());
        }
示例#3
0
        public bool CreateManager(string firstName, string lastName, string middleName, string email, string password, string checkPassword)
        {
            if (password.Equals(checkPassword))
            {
                Manager newManager = new Manager
                {
                    FirstName  = firstName,
                    LastName   = lastName,
                    MiddleName = middleName,
                    Email      = email,
                    Password   = password
                };
                int managerId = _managerRepository.CreateManager(newManager);

                return(true);
            }
            else
            {
                return(false);
            }
        }