private IList <HuntsmanDto> ToDtos(IList <Entities.Huntsman> entityList) { var dtos = new List <HuntsmanDto>(); foreach (Entities.Huntsman entity in entityList) { HuntsmanDto dto = ToDto(entity); dtos.Add(dto); } return(dtos); }
public HuntsmanDto GetById(int huntsmanId) { using (var db = new DbContext()) { Entities.Huntsman huntsman = db.Huntsman.Find(huntsmanId); HuntsmanDto dto = ToDto(huntsman); return(dto); } }
private HuntsmanDto ToDto(Entities.Huntsman entity) { var dto = new HuntsmanDto { Id = entity.Id, Name = entity.Name, LastName = entity.LastName, Role = entity.Role }; return(dto); }
public int Insert(HuntsmanDto dto) { var entity = new Entities.Huntsman { Id = dto.Id, Name = dto.Name, LastName = dto.LastName, Role = dto.Role }; using (var db = new DbContext()) { Entities.Huntsman huntsman = db.Huntsman.Add(entity); db.SaveChanges(); return(huntsman.Id); } }
public static bool IsDirector(HttpCookie userIdCookie) { if (userIdCookie == null) { return(false); } string userIdString = userIdCookie["UserId"]; if (!Int32.TryParse(userIdString, out int userId)) { return(false); } UserDto user = _userDao.GetById(userId); HuntsmanDto huntsman = _huntsmanDao.GetById(user.HuntsmanId); return(huntsman.Role.Equals("Zarząd")); }