Ejemplo n.º 1
0
        public static async Task UpdateRaffle(this AppDbContext db, RaffleModel model)
        {
            if (model.Validate())
            {
                var raffle = await db.Raffles.FindAsync(model.id);

                raffle.Title     = model.title;
                raffle.EventDate = model.eventDate;
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 2
0
        public static RaffleModel CastToRaffle(this Raffle raffle)
        {
            var model = new RaffleModel
            {
                id         = raffle.Id,
                eventDate  = raffle.EventDate,
                isComplete = raffle.IsComplete,
                title      = raffle.Title
            };

            return(model);
        }
Ejemplo n.º 3
0
        public ObservableCollection <RaffleModel> GetRaffleModelFrom(
            ICollection <Raffle> entities)
        {
            ObservableCollection <RaffleModel> collection =
                new ObservableCollection <RaffleModel>();

            foreach (Raffle entity in entities)
            {
                RaffleModel model = new RaffleModel(entity);
                collection.Add(model);
            }
            return(collection);
        }
Ejemplo n.º 4
0
        public static bool Validate(this RaffleModel model)
        {
            if (model.eventDate == DateTime.MinValue)
            {
                throw new Exception("Raffle must specify an event date");
            }

            if (string.IsNullOrEmpty(model.title))
            {
                throw new Exception("Raffle must have a title");
            }

            return(true);
        }
Ejemplo n.º 5
0
        private void AddRaffle()
        {
            var raffle = new Raffle {
                Name     = "<Enter Name, and Select Items and Participants>",
                Location = new ContactDetails()
                {
                    Address1 = "<Enter Location and Contact Details>"
                },
                RaffleParticipants = new ObservableCollection <RaffleParticipant>(),
                RaffleItems        = new ObservableCollection <RaffleItem>()
            };

            uow.Raffles.Add(raffle);
            SelectedRaffle = new RaffleModel(raffle);
            Raffles.Add(SelectedRaffle);
            ClearSelectedItems();
            ClearSelectedParticipants();
        }
Ejemplo n.º 6
0
        public static async Task <int> AddRaffle(this AppDbContext db, RaffleModel model)
        {
            if (model.Validate())
            {
                var raffle = new Raffle
                {
                    EventDate  = model.eventDate,
                    IsComplete = false,
                    Title      = model.title
                };

                await db.Raffles.AddAsync(raffle);

                await db.SaveChangesAsync();

                return(raffle.Id);
            }

            return(0);
        }
Ejemplo n.º 7
0
 public async Task UpdateRaffle([FromBody] RaffleModel model)
 {
     await db.UpdateRaffle(model);
 }
Ejemplo n.º 8
0
 public async Task <int> AddRaffle([FromBody] RaffleModel model)
 {
     return(await db.AddRaffle(model));
 }