// GET: Profile public ActionResult Index() { if (_rolesManager.SetCurrentEmployee(_employeeDataAccess, GetCurrentUserEmail())) { if (_rolesManager.LoggedInEmployee.Profile == null) { _rolesManager.LoggedInEmployee.Profile = new Profile { Id = _rolesManager.LoggedInEmployee.Id }; _profileDataAccess.CreateProfile(_rolesManager.LoggedInEmployee.Profile); return(RedirectToAction("Index")); //HACK: reload to avoid ununderstandable Null exception!! } ViewBag.ProfilePic = _rolesManager.LoggedInEmployee.Profile.ProfilePic; ViewBag.Access = "FullAccess"; return(View("Details", _rolesManager.LoggedInEmployee)); } ViewBag.ErrorMsg = "You are not registered on our system. Plz contact the system administrator if u think this is wrong."; return(View("Error")); }
public async Task <IActionResult> Post([FromBody] CreateUserProfileRequest profile) { try { if (!ModelState.IsValid) { return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = true, StatusCode = ((int)ResponseStatus.BadRequest).ToString(), Message = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)) })); } ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.CreateProfile(profile); if (response.ResponseCode == (int)DbReturnValue.CreateSuccess) { DatabaseResponse userResponse = await _profileAccess.GetUserProfileById(((UserMaster)response.Results).Id); if (userResponse.ResponseCode == (int)DbReturnValue.RecordExists) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreateSuccess), ReturnedObject = userResponse.Results })); } else { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreationFailed) })); } } else if (response.ResponseCode == (int)DbReturnValue.EmailExists) { Log.Error(EnumExtensions.GetDescription(DbReturnValue.EmailExists)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.EmailExists), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.CreationFailed)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreationFailed), ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }