Ejemplo n.º 1
0
        public static string BuildSlotRange(Field field)
        {
            if (field.Slots.Count == 0) return string.Empty;

            if (field.Slots.All(s => s.StartDateTime.Date == s.EndDateTime.Date)) return field.Slots[0].StartDateTime.ToString("M/d/yy");

            var sortedSlots = field.Slots.OrderBy(s => s.StartDateTime);

            return string.Format("{0} - {1}",
                                 sortedSlots.First().StartDateTime.ToString("M/d/yy"),
                                 sortedSlots.Last().StartDateTime.ToString("M/d/yy"));
        }
        public static List<FieldConflictViewModel> LoadList(DbSet<Field> fields, Field fieldInQuestion = null)
        {
            var list = new List<FieldConflictViewModel>();

            foreach (Field field in fields.OrderBy(f => f.Description))
            {
                if (fieldInQuestion == null || fieldInQuestion != field)
                {
                    list.Add(new FieldConflictViewModel
                                 {
                                     Id = field.Id,
                                     Description = field.Description
                                 });
                }
            }

            return list;
        }
Ejemplo n.º 3
0
        public static FieldViewModel Load(Field field)
        {
            FieldViewModel vm =  Mapper.Map<Field, FieldViewModel>(field);

            vm.CanBeDeleted = field.CanBeDeleted();

            vm.SlotRange = BuildSlotRange(field);

            return vm;
        }