示例#1
0
        public IHttpActionResult PutEtisalatCash(int id, EtisalatCash etisalatCash)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != etisalatCash.Id)
            {
                return(BadRequest());
            }

            db.Entry(etisalatCash).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EtisalatCashExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotModified));
                }
            }

            return(Ok(etisalatCash));
        }
示例#2
0
        public IHttpActionResult GetEtisalatCash(int id)
        {
            EtisalatCash etisalatCash = db.EtisalatCashs.Include(ec => ec.Event).SingleOrDefault();

            if (etisalatCash == null)
            {
                return(NotFound());
            }

            return(Ok(etisalatCash));
        }
示例#3
0
        public IHttpActionResult PostEtisalatCash(EtisalatCash etisalatCash)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.EtisalatCashs.Add(etisalatCash);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = etisalatCash.Id }, etisalatCash));
        }
示例#4
0
        public IHttpActionResult DeleteEtisalatCash(int id)
        {
            EtisalatCash etisalatCash = db.EtisalatCashs.Find(id);

            if (etisalatCash == null)
            {
                return(NotFound());
            }

            db.EtisalatCashs.Remove(etisalatCash);
            db.SaveChanges();

            return(Ok(etisalatCash));
        }
        // POST: api/Events

        public IHttpActionResult PostEvent([FromBody] EventsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var @event = new Event();

            @event.Name    = model.Name;
            @event.Prize_1 = model.Prize_1;
            @event.Prize_2 = model.Prize_2;
            @event.Prize_3 = model.Prize_3;
            @event.Host_1  = model.Host_1;
            @event.Host_2  = model.Host_2;
            @event.Host_3  = model.Host_3;
            //@event.Date = model.Date.Date;
            //@event.Time = model.Time;
            @event.Entry_Fees     = model.Entry_Fees;
            @event.No_Of_Players  = model.No_Of_Players;
            @event.Type           = model.Type;
            @event.Match_Duration = model.Match_Duration;
            @event.Address        = model.Address;
            @event.Location_URL   = model.Location_URL;

            db.Events.Add(@event);
            db.SaveChanges();
            foreach (var item in model.VodafoneCashNumbers)
            {
                var Vodafone = new VodafoneCash();
                Vodafone.Number   = item;
                Vodafone.Count    = 0;
                Vodafone.Event_ID = @event.Id;
                db.VodafoneCashs.Add(Vodafone);
            }
            foreach (var item in model.EtisalatCashNumbers)
            {
                var Etisalat = new EtisalatCash();
                Etisalat.Number   = item;
                Etisalat.Count    = 0;
                Etisalat.Event_ID = @event.Id;
                db.EtisalatCashs.Add(Etisalat);
            }
            db.SaveChanges();

            return(Created(new Uri(Request.RequestUri + "/" + @event.Id), @event));
        }
        public IHttpActionResult PutEvent(int id, EventsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != model.Id)
            {
                return(BadRequest());
            }

            var dbevent = db.Events.SingleOrDefault(e => e.Id == id);

            if (dbevent == null)
            {
                return(NotFound());
            }

            dbevent.Name    = model.Name;
            dbevent.Prize_1 = model.Prize_1;
            dbevent.Prize_2 = model.Prize_2;
            dbevent.Prize_3 = model.Prize_3;
            dbevent.Host_1  = model.Host_1;
            dbevent.Host_2  = model.Host_2;
            dbevent.Host_3  = model.Host_3;
            //dbevent.Date = model.Date.Date;
            //dbevent.Time = model.Time;
            dbevent.Entry_Fees     = model.Entry_Fees;
            dbevent.No_Of_Players  = model.No_Of_Players;
            dbevent.Type           = model.Type;
            dbevent.Match_Duration = model.Match_Duration;
            dbevent.Address        = model.Address;
            dbevent.Location_URL   = model.Location_URL;



            for (int i = 0; i < model.VodafoneCashNumbers.Count; i++)
            {
                var v = db.VodafoneCashs.Where(vo => vo.Event_ID == model.Id).OrderBy(vf => vf.Id).Skip(i).Take(1).FirstOrDefault();
                if (v != null)
                {
                    v.Number = model.VodafoneCashNumbers[i];
                }
                else
                {
                    var Vodafone = new VodafoneCash();
                    Vodafone.Number   = model.VodafoneCashNumbers[i];
                    Vodafone.Count    = 0;
                    Vodafone.Event_ID = model.Id;
                    db.VodafoneCashs.Add(Vodafone);
                }
            }

            for (int i = 0; i < model.EtisalatCashNumbers.Count; i++)
            {
                var e = db.EtisalatCashs.Where(et => et.Event_ID == model.Id).OrderBy(vf => vf.Id).Skip(i).Take(1).FirstOrDefault();
                if (e != null)
                {
                    e.Number = model.EtisalatCashNumbers[i];
                }
                else
                {
                    var Etisalat = new EtisalatCash();
                    Etisalat.Number   = model.EtisalatCashNumbers[i];
                    Etisalat.Count    = 0;
                    Etisalat.Event_ID = model.Id;
                    db.EtisalatCashs.Add(Etisalat);
                }
            }

            try
            {
                int c = db.SaveChanges();
            }
            catch (Exception)
            {
                if (!EventExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotModified));
                }
            }

            return(Ok(model));
        }
示例#7
0
        public ActionResult Save(EventsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("New", model));
            }
            if (model.Id == 0)
            {
                var @event = new Event();
                @event.Name    = model.Name;
                @event.Prize_1 = model.Prize_1;
                @event.Prize_2 = model.Prize_2;
                @event.Prize_3 = model.Prize_3;
                @event.Host_1  = model.Host_1;
                @event.Host_2  = model.Host_2;
                @event.Host_3  = model.Host_3;
                //@event.Date = model.Date.Date;
                //@event.Time = model.Time;
                @event.Entry_Fees     = model.Entry_Fees;
                @event.No_Of_Players  = model.No_Of_Players;
                @event.Type           = model.Type;
                @event.Match_Duration = model.Match_Duration;
                @event.Address        = model.Address;
                @event.Location_URL   = model.Location_URL;

                _context.Events.Add(@event);
                _context.SaveChanges();
                foreach (var item in model.VodafoneCashNumbers)
                {
                    var Vodafone = new VodafoneCash();
                    Vodafone.Number   = item;
                    Vodafone.Count    = 0;
                    Vodafone.Event_ID = @event.Id;
                    _context.VodafoneCashs.Add(Vodafone);
                }
                foreach (var item in model.EtisalatCashNumbers)
                {
                    var Etisalat = new EtisalatCash();
                    Etisalat.Number   = item;
                    Etisalat.Count    = 0;
                    Etisalat.Event_ID = @event.Id;
                    _context.EtisalatCashs.Add(Etisalat);
                }
            }
            else
            {
                var dbevent = _context.Events.SingleOrDefault(e => e.Id == model.Id);
                dbevent.Name    = model.Name;
                dbevent.Prize_1 = model.Prize_1;
                dbevent.Prize_2 = model.Prize_2;
                dbevent.Prize_3 = model.Prize_3;
                dbevent.Host_1  = model.Host_1;
                dbevent.Host_2  = model.Host_2;
                dbevent.Host_3  = model.Host_3;
                //dbevent.Date = model.Date.Date;
                //dbevent.Time = model.Time;
                dbevent.Entry_Fees     = model.Entry_Fees;
                dbevent.No_Of_Players  = model.No_Of_Players;
                dbevent.Type           = model.Type;
                dbevent.Match_Duration = model.Match_Duration;
                dbevent.Address        = model.Address;
                dbevent.Location_URL   = model.Location_URL;

                for (int i = 0; i < model.VodafoneCashNumbers.Count; i++)
                {
                    var v = _context.VodafoneCashs.Where(vo => vo.Event_ID == model.Id).OrderBy(vf => vf.Id).Skip(i).Take(1).FirstOrDefault();
                    if (v != null)
                    {
                        v.Number = model.VodafoneCashNumbers[i];
                    }
                    else
                    {
                        var Vodafone = new VodafoneCash();
                        Vodafone.Number   = model.VodafoneCashNumbers[i];
                        Vodafone.Count    = 0;
                        Vodafone.Event_ID = model.Id;
                        _context.VodafoneCashs.Add(Vodafone);
                    }
                }

                for (int i = 0; i < model.EtisalatCashNumbers.Count; i++)
                {
                    var e = _context.EtisalatCashs.Where(et => et.Event_ID == model.Id).OrderBy(vf => vf.Id).Skip(i).Take(1).FirstOrDefault();
                    if (e != null)
                    {
                        e.Number = model.EtisalatCashNumbers[i];
                    }
                    else
                    {
                        var Etisalat = new EtisalatCash();
                        Etisalat.Number   = model.EtisalatCashNumbers[i];
                        Etisalat.Count    = 0;
                        Etisalat.Event_ID = model.Id;
                        _context.EtisalatCashs.Add(Etisalat);
                    }
                }
            }
            _context.SaveChanges();
            return(RedirectToAction("Index", "Events"));
        }