Пример #1
0
        public JsonResult EditDate(int id, string strStartTime, string strEndTime)
        {
            aevent aevent = this.repository.Events.SingleOrDefault(a => a.id == id);

            if (aevent == null)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (strStartTime != null && strStartTime.Length > 0)
                {
                    aevent.startTime = DateTime.Parse(strStartTime);
                }
                if (strEndTime != null && strEndTime.Length > 0)
                {
                    aevent.endTime = DateTime.Parse(strEndTime);
                }

                if (this.repository.SaveEvent(aevent))
                {
                    //SendEventByEmail(emailsender, aevent);

                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }
        }
Пример #2
0
        //
        // GET: /Events/Details/5

        public ActionResult Details(int id = 0)
        {
            aevent aevent = this.repository.Events.SingleOrDefault(a => a.id == id);

            if (aevent == null)
            {
                return(HttpNotFound());
            }
            return(View(aevent));
        }
Пример #3
0
        // GET api/Events/5
        public aevent Getaevent(int id)
        {
            aevent aevent = db.aevents.First(c => c.id == id);

            if (aevent == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(aevent);
        }
Пример #4
0
        //
        // GET: /Events/Edit/5

        public ActionResult Edit(int id = 0)
        {
            aevent aevent = this.repository.Events.SingleOrDefault(a => a.id == id);
            List <SelectListItem> users = getUsers();

            ViewBag.users = users;
            if (aevent == null)
            {
                return(HttpNotFound());
            }
            return(View(aevent));
        }
Пример #5
0
 public bool DeleteEvent(aevent aevent)
 {
     try
     {
         context.aevent.Remove(aevent);
         context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #6
0
        public JsonResult DeleteConfirmed(int id)
        {
            aevent aevent = repository.Events.SingleOrDefault(l => l.id == id);

            if (repository.DeleteEvent(aevent))
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Пример #7
0
        public ActionResult Edit(aevent aevent)
        {
            if (ModelState.IsValid)
            {
                if (this.repository.SaveEvent(aevent))
                {
                    //SendEventByEmail(emailsender, aevent);

                    return(RedirectToAction("Index"));
                }
            }
            //List<SelectListItem> users = getUsers();
            //ViewBag.users = users;
            return(View(aevent));
        }
Пример #8
0
        // POST api/Events
        public HttpResponseMessage Postaevent(aevent aevent)
        {
            if (ModelState.IsValid)
            {
                db.aevents.AddObject(aevent);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, aevent);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = aevent.id }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Пример #9
0
 public bool SaveEvent(aevent aevent)
 {
     if (aevent.id == 0)
     {
         context.aevent.Add(aevent);
     }
     else
     {
         context.aevent.Find(aevent.id).CopyFrom(aevent);
     }
     try{
         context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #10
0
        // DELETE api/Events/5
        public HttpResponseMessage Deleteaevent(int id)
        {
            aevent aevent = db.aevents.First(c => c.id == id);

            if (aevent == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.aevents.DeleteObject(aevent);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, aevent));
        }
Пример #11
0
        // PUT api/Events/5
        public HttpResponseMessage Putaevent(int id, aevent aevent)
        {
            if (ModelState.IsValid && id == aevent.id)
            {
                //db.Entry(aevent).State = System.Data.Entity.EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Пример #12
0
 private void SendEventByEmail(IEmailSender emailsender, aevent aevent)
 {
     emailsender.SendMail(aevent);
 }