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)); }
public ActionResult CreateManager(ManagerViewModel managerViewModel) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Sector Error"); return(View()); } _managerRepository.CreateManager(managerViewModel); return(View()); }
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); } }