Exemple #1
0
        public async Task <IActionResult> Register(RegisterModel model)
        {
            var appuser = new AppUser();

            if (model.employeeId != null)
            {
                var emp = await _icore.GetEmployeeById(model.employeeId.Value);

                if (emp != null)
                {
                    //appuser.EmployeeId = model.employeeId;
                }
            }
            appuser.UserName = model.username;
            appuser.Email    = model.email;

            var r = await _userManager.CreateAsync(appuser, model.password);

            var mlist = new List <string>();

            if (!r.Succeeded)
            {
                var messages = r.Errors.Select(u => u.Description).ToArray();
                return(Ok(new ResponseModel(messages)));
            }
            else
            {
                return(Ok(new ResponseModel(true)));
            }
        }
Exemple #2
0
        public async Task <IActionResult> GetEmployee(int id)
        {
            var emp = await _coreRep.GetEmployeeById(id);

            if (emp != null)
            {
                return(Ok(new ResponseModel(new
                                            EmployeeModel(emp))));
            }
            return(NotFound());
        }
        public async Task <IActionResult> AddEmployeeReceiver(int id)
        {
            var employee = await _icore.GetEmployeeById(id);

            if (employee == null)
            {
                return(NotFound());
            }
            var receiver = await _imessage.AddEmployeeReceiver(employee, await _userManager.GetUserAsync(User), DateTime.Now);

            var model = new MessageReceiverModel(receiver);

            return(Ok(new ResponseModel(model)));
        }
Exemple #4
0
        public async Task <MessageReceiver> AddEmployeeReceiver(Employee employee, AppUser actor, DateTime?at)
        {
            var emp = await _core.GetEmployeeById(employee.Id);

            if (emp == null)
            {
                throw new EntityNotFound(typeof(Employee), employee.Id);
            }
            var receiver = new MessageReceiver();

            receiver.FullName   = emp.Person.FullName;
            receiver.ShortName  = emp.Person.DisplayName;
            receiver.EmployeeId = emp.Id;
            var entity = await _res.AddDetail(receiver, DateTime.Now, actor);

            return(entity);
        }