Ejemplo n.º 1
0
        public Sitting Delete(Sitting sitting)
        {
            context.Sittings.Remove(sitting);
            context.SaveChanges();

            return(sitting);
        }
Ejemplo n.º 2
0
        public Sitting Update(Sitting updateSitting)


        {
            var _sitting = context.Sittings.Attach(updateSitting);

            _sitting.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(updateSitting);
        }
Ejemplo n.º 3
0
        public bool ValidateDate(Sitting a)
        {
            var sittingItems = GetSittingWithType().Where(e => e.Start.Date == DateTime.Now.Date).ToList();
            var validateItem = true;

            foreach (var s in sittingItems)
            {
                if (a.End <= a.Start || a.Start >= s.End)
                {
                    return(validateItem);
                }
                else
                {
                    validateItem = false;
                    return(validateItem);
                }
            }
            return(validateItem);
        }
Ejemplo n.º 4
0
        public void AddSitting(Sitting sitting)
        {
            var days = (sitting.End - sitting.Start).TotalDays;

            for (var i = 0; i < days; i++)
            {
                DateTime newDateTime = new DateTime(sitting.Start.AddDays(i).Year, sitting.Start.AddDays(i).Month, sitting.Start.AddDays(i).Day) + sitting.End.TimeOfDay;
                var      newsitting  = new Sitting()
                {
                    Start         = sitting.Start.AddDays(i),
                    End           = newDateTime,
                    Capacity      = sitting.Capacity,
                    SittingTypeId = sitting.SittingTypeId,
                    SittingType   = sitting.SittingType,
                    Status        = sitting.Status
                };
                context.Sittings.Add(newsitting);
                context.SaveChanges();
            }
        }