Ejemplo n.º 1
0
        public static ProductSessionDto ToDto(this ProductSession e)
        {
            if (e == null)
            {
                return(null);
            }

            var res = new ProductSessionDto();

            res.Id           = e.Id;
            res.IdProduct    = e.IdProduct;
            res.Description  = e.Description;
            res.CreationDate = e.XCreateDate;
            res.IdTeacher    = e.IdTeacher;
            res.ProductSessionAttendances = e.ProductSessionAttendances.OrderBy(x => x.CustomerFullName).Select(x => x.ToDto()).ToList();
            res.Teacher   = e.Teacher?.ToDto();
            res.IdTeacher = e.IdTeacher;
            return(res);
        }
Ejemplo n.º 2
0
        public async Task <ProductSessionDto> SaveSubscribers(ProductSessionDto item)
        {
            var subscribers = await _dbCtx.ProductSessionAttendances.Where(x => x.IdSession == item.Id).ToArrayAsync();

            foreach (var s in subscribers)
            {
                var newElemenet = item.ProductSessionAttendances.FirstOrDefault(x => x.Id == s.Id);
                if (newElemenet != null)
                {
                    s.Present = newElemenet.Present;
                }
            }
            _dbCtx.ProductSessionAttendances.UpdateRange(subscribers);
            await _dbCtx.SaveChangesAsync();

            var res = await _dbCtx.ProductSessions.FindAsync(item.Id);

            return(res.ToDto());
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <ProductSessionDto> > SaveSubscribers([FromBody] ProductSessionDto value)
        {
            var res = await _service.SaveSubscribers(value);

            return(res);
        }