Ejemplo n.º 1
0
        public async Task <IActionResult> AddEmployee([FromBody] Employee model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var empId = await serviceapi.AddEmployee(model);

                    if (empId == 0)
                    {
                        return(Ok("Only one employee with no manager is allowed. Kinldy provide a manager ID."));
                    }
                    else if (empId != 0 || empId != 1)
                    {
                        return(Ok("Employee created successfully. Email has been sent to the user."));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }