public ResponseViewModel <UserViewModel> IsValidForInsert(UserViewModel model, LoginViewModel loggedUser, VacationCalendarContext context) { var response = new ResponseViewModel <UserViewModel>(); if (model == null) { response.Success = false; response.ResponseMessages.Add(ApplicationConstants.ERROR); return(response); } response.Success = true; if (loggedUser.Role != Role.Admin) { response.ResponseMessages.Add("Not allowed to manipulate data for requested user!"); response.Success = false; return(response); } if (model.Id != default(int)) { response.ResponseMessages.Add("Id must be empty!"); response.Success = false; } if (model.BirthDate == default(DateTime)) { response.ResponseMessages.Add("Birth date cannot be empty!"); response.Success = false; } if (string.IsNullOrEmpty(model.FirstName)) { response.ResponseMessages.Add("First name cannot be empty!"); response.Success = false; } if (string.IsNullOrEmpty(model.LastName)) { response.ResponseMessages.Add("Last name cannot be empty!"); response.Success = false; } if (string.IsNullOrEmpty(model.UserName)) { response.ResponseMessages.Add("User name cannot be empty!"); response.Success = false; } else { var existingUsername = context.Users.SingleOrDefault(x => x.UserName == model.UserName)?.UserName; if (existingUsername != default(string)) { response.ResponseMessages.Add("User name already exists! Please choose another one!"); response.Success = false; } } if (string.IsNullOrEmpty(model.OfficeCountryCode)) { response.ResponseMessages.Add("Office Country code cannot be empty!"); response.Success = false; } if (string.IsNullOrEmpty(model.Role)) { response.ResponseMessages.Add("Role code cannot be empty!"); response.Success = false; } return(response); }
public UserService(VacationCalendarContext context, UserDataValidator validator) { _context = context; _validator = validator; }
public VacationDataService(VacationCalendarContext context, VacationDataValidator validator) { _context = context; _validator = validator; }
public LoginService(VacationCalendarContext context, IOptions <AppSettings> appSettings) { _context = context; _appSettings = appSettings.Value; }
public CalendarService(VacationCalendarContext context, IVacationDataService vacationService, IStaticListsService staticListsService) { _context = context; _vacationService = vacationService; _staticListsService = staticListsService; }