Exemplo n.º 1
0
        public async Task <IActionResult> EditStaff(EditStaffViewModel model)
        {
            if (ModelState.IsValid)
            {
                var updClientResult = await _dbUsers.ClientUpdateAsync(model);

                if (!updClientResult.isSuccess)
                {
                    foreach (var err in updClientResult.errors)
                    {
                        ModelState.AddModelError(string.Empty, err);
                    }

                    return(View());
                }

                var updOrgResult = await _dbOrgStaff.ChangeOrgForStaff(model.Id, model.OrgId);

                if (!updOrgResult)
                {
                    ModelState.AddModelError(string.Empty, "Company has not changed.");
                    return(View());
                }
            }

            return(RedirectToAction(nameof(EditStaff), "ManageUsers", new { id = model.Id }));
        }