public async Task <bool> UpdateAuthor(LookupItemModel model) { var author = _mapper.Map <Domain.Author>(model); _context.Authors.Update(author); _cache.Remove(CacheKeys.Authors); return(await _context.SaveChangesAsync() > 0); }
/// <summary> /// Get current logined user /// </summary> /// <returns></returns> /// CALL URL: _vti_bin/Services/Employee/EmployeeService.svc/GetCurrentUser public CurrentUserModel GetCurrentUser() { try { CurrentUserModel user = new CurrentUserModel(); //Get Current Login User SPUser spUser = SPContext.Current.Web.CurrentUser; if (spUser.IsSiteAdmin) { user.IsSystemAdmin = true; //return user; } var employeeDal = new EmployeeInfoDAL(SPContext.Current.Web.Url); EmployeeInfo currentEmployee = HttpContext.Current.Session[StringConstant.SessionString.EmployeeLogedin] as EmployeeInfo; if (currentEmployee == null) { if (spUser != null) { int currentLoginName = spUser.ID; currentEmployee = employeeDal.GetByADAccount(currentLoginName); } } if (currentEmployee != null) { user = new CurrentUserModel() { ID = currentEmployee.ID, EmployeeID = currentEmployee.EmployeeID, Department = LookupItemModel.ConvertFromEntity(currentEmployee.Department), Location = LookupItemModel.ConvertFromEntity(currentEmployee.FactoryLocation), FullName = currentEmployee.FullName, EmployeePosition = (currentEmployee.EmployeePosition != null && currentEmployee.EmployeePosition.LookupId > 0) ? currentEmployee.EmployeePosition.LookupId : 0 }; if (user.Department != null && user.Department.LookupId > 0) { var departmentDetail = _departmentDAL.GetByID(user.Department.LookupId); if (departmentDetail != null) { user.IsBODApprovalRequired = departmentDetail.IsBODApprovalRequired; } } } return(user); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("STADA - Employee Service - GetCurrentUser fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
public static LookupItem ConvertToEntity(LookupItemModel model) { if (model != null) { return new LookupItem { LookupId = model.LookupId, LookupValue = model.LookupValue } } ; return(new LookupItem()); }
public async Task <int> CreateAuthor(LookupItemModel model) { // todo: validate var author = _mapper.Map <Domain.Author>(model); _context.Authors.Add(author); _cache.Remove(CacheKeys.Authors); await _context.SaveChangesAsync(); return(author.Id); }
public static LookupItemModel Map(this LookupItem original) { if (original == null) { return(null); } var lookup = new LookupItemModel() { Value = original.ID.ToString(), Text = original.Caption }; return(lookup); }
public async Task <IActionResult> UpdateAuthor([FromBody] LookupItemModel author) { try { var status = await _lookupDataRepository.UpdateAuthor(author); return(Ok(status)); } catch (Exception ex) { this._telemetry.TrackException(ex); var response = LookupResponse <AudioBookItemModel> .BuildErrorResponse("FailedUpadteAuthor", "Could not update Author"); return(BadRequest(response)); } }