public FacultyDTO Update(long id, FacultyDTO faculty) { FACULTY facToUpdate, updatedFac, oldFac; FacultyDTO retVal; retVal = null; oldFac = facultyRepository.GetById(id); if (CheckHelper.IsFilled(faculty) && CheckHelper.IsFilled(oldFac)) { try { facToUpdate = transformer.TransformFromDTO(id, faculty); facToUpdate.READING_ROOM = oldFac.READING_ROOM; facToUpdate.BLOGs = oldFac.BLOGs; facToUpdate.USERs = oldFac.USERs; updatedFac = facultyRepository.Update(facToUpdate); if (CheckHelper.IsFilled(updatedFac)) { retVal = transformer.TransformToDTO(updatedFac); } } catch (Exception) { } } return(retVal); }
public async Task <Specialty> Create(Specialty speciality) { List <Task> tasks = new List <Task>(); var facultyIdExists = _facultyRepository.GetById(speciality.FacultyId); tasks.Add(facultyIdExists); var uniqueId = _specialtyRepository.GetById(speciality.Id); tasks.Add(uniqueId); var uniqueName = _specialtyRepository.GetByName(speciality.Name); tasks.Add(uniqueName); await Task.WhenAll(tasks); var lectorIdExists = _lectorRepository.GetById(speciality.LectorId) != null; if (facultyIdExists.Result != null && lectorIdExists && uniqueId.Result == null && uniqueName.Result == null) { return(await _specialtyRepository.Create(speciality)); } else { throw new Exception(); } }
public HttpResponseMessage GetInstitutesInFaculty(HttpRequestMessage request, int facultyId) { var faculty = _facultyRepository.GetById(facultyId); if (faculty == null) { return(request.CreateErrorResponse( HttpStatusCode.NotFound, string.Format("Not found faculty with id:{0}", facultyId))); } var mapped = faculty.Institutes.Select(Mapper.Map <InstituteDTO>).ToList(); return(request.CreateResponse(mapped)); }
public UserDTO Add(UserDTO user) { USER userToAdd, addedUser; UserDTO retVal; retVal = null; if (CheckHelper.IsFilled(user)) { try { userToAdd = transformer.TransformFromDTO(-1, user); addedUser = userRepository.Add(userToAdd); if (CheckHelper.IsFilled(addedUser)) { addedUser.FACULTY = facultyRepository.GetById(user.FacultyId); retVal = transformer.TransformToDTO(addedUser); } } catch (Exception e) { } } return(retVal); }
public ReadingRoomDTO Add(ReadingRoomDTO rroom) { READING_ROOM rroomToAdd, addedRRoom; ReadingRoomDTO retVal; SEAT seat; List <SEAT> seats = new List <SEAT>(); long seatID; retVal = null; if (CheckHelper.IsFilled(rroom)) { try { seatID = seatRepository.getNextId(); for (int i = 0; i < rroom.Dimension; i++) { seat = new SEAT() { SEAT_LABEL = "" + (i + 1), SEAT_POSITION = i + 1, RROOM_ID = rroom.Id, SEAT_ID = seatID + i }; seats.Add(seat); } rroomToAdd = transformer.TransformFromDTO(-1, rroom); rroomToAdd.SEATs = seats; addedRRoom = rroomRepository.Add(rroomToAdd); if (CheckHelper.IsFilled(addedRRoom)) { addedRRoom.FACULTY = facultyRepository.GetById(rroom.FacultyId); retVal = transformer.TransformToDTO(addedRRoom); } } catch (Exception) { throw; } } return(retVal); }
public University GetUniversityByFacultyId(short facultyId) { var faculty = _facultyRepository.GetById(facultyId); if (faculty != null) { return(_universityRepository.GetSingle(u => u.UniversityFaculties.Any(uf => uf.FacultyId == facultyId))); } return(null); }
public async Task <ActionResult <Faculty> > Edit(string id) { if (!string.IsNullOrEmpty(id)) { var Faculty = await _Faculty.GetById(id); return(View(Faculty)); } else { return(BadRequest()); } }
public FacultyDTO GetFacultyById(int facultyId) { var faculty = _facultyRepository.GetById(facultyId); if (faculty == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var mapped = Mapper.Map <FacultyDTO>(faculty); return(mapped); }
// GET: Faculties/Details/{id} public ActionResult Details(int id) { Faculty faculty = _facultyRepository.GetById(id); if (faculty == null) { return(HttpNotFound()); } var reviewList = _reviewRepository.GetMany(review => review.FacultyId.Equals(id)); List <DataPoint> dataPoints = new List <DataPoint> { new DataPoint(1, reviewList.Where(review => review.Value.Equals(1)).Count()), new DataPoint(2, reviewList.Where(review => review.Value.Equals(2)).Count()), new DataPoint(3, reviewList.Where(review => review.Value.Equals(3)).Count()), new DataPoint(4, reviewList.Where(review => review.Value.Equals(4)).Count()), new DataPoint(5, reviewList.Where(review => review.Value.Equals(5)).Count()), }; ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints); return(View(faculty)); }
// GET: Programmes/{facultyId} public ActionResult Index(int facultyId) { Faculty faculty = _facultyRepository.GetById(facultyId); if (faculty == null) { return(HttpNotFound()); } ViewBag.FacultyName = faculty.Name; ViewBag.FacultyId = facultyId; IEnumerable <Programme> programmes = _programmeRepository.GetMany(programme => programme.FacultyId == facultyId); return(View(programmes)); }
public async Task <Models.Users.User> UpdateUser(int userId, int teamId, int facultyId, string email, int userPositionId) { var user = await _userRepository.GetById(userId); if (user == null) { return(null); } if (email != user.Email) { var validEmail = await _userRepository.GetByEmail(email) == null; if (!validEmail) { return(null); } user.Email = email; } var validTeam = _teamRepository.GetById(teamId) != null; if (validTeam) { user.TeamID = teamId; } var validFaculty = await _facultyRepository.GetById(facultyId) != null; if (validFaculty) { user.FacultylID = facultyId; } var validUserPosition = await _userPositionRepository.GetById(userPositionId) != null; if (validUserPosition) { user.UserPositionId = userPositionId; } var result = await _userRepository.Update(user); return(result); }
public async Task <Lector> UpdateFaculty(int facultyId, int lectorId) { var lector = await _lectorRepository.GetById(lectorId); if (lector == null) { return(null); } var faculty = await _facultyRepository.GetById(facultyId); if (faculty == null) { return(null); } lector.FacultyId = facultyId; var result = await _lectorRepository.Update(lector); return(result); }
public Faculty GetById(int id) { return(_facultyRepository.GetById(id)); }
public Faculty GetFacultyById(short id) { return(_facultyRepository.GetById(id)); }
public async Task <FacultyModel> GetById(Guid id) { var faculty = await repository.GetById(id); return(mapper.Map <FacultyModel>(faculty)); }
public Faculty GetFacultyById(int id) { return(_facultyService.GetById(id)); }
public async Task <Faculty> GetById(int facultyId) { return(await _facultyService.GetById(facultyId)); }