Пример #1
0
        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);
        }
Пример #2
0
        public HuntsmanDto GetById(int huntsmanId)
        {
            using (var db = new DbContext())
            {
                Entities.Huntsman huntsman = db.Huntsman.Find(huntsmanId);

                HuntsmanDto dto = ToDto(huntsman);

                return(dto);
            }
        }
Пример #3
0
        private HuntsmanDto ToDto(Entities.Huntsman entity)
        {
            var dto = new HuntsmanDto
            {
                Id       = entity.Id,
                Name     = entity.Name,
                LastName = entity.LastName,
                Role     = entity.Role
            };

            return(dto);
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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"));
        }