public ActionResult Create([Bind(Include = "Id,EventTitle,Abstract,EventDescription,StartDate,EndDate,Location,Url,Price,EventGroupTitle,EventGroupName,EventTypeOne")] CalendarEvent calendarevent)
 {
     if (ModelState.IsValid)
     {
         using (EventOrganizerEntities db = new EventOrganizerEntities())
         {
             try
             {
                 calendarevent.CreatedDateTime    = DateTime.UtcNow;
                 calendarevent.LastUpdateDateTime = DateTime.UtcNow;
                 calendarevent.IsDeleted          = false;
                 db.CalendarEvents.Add(calendarevent);
                 db.SaveChanges();
                 return(Content("Event has been created successfully!"));
             }
             catch (Exception ex)
             {
                 return(Content("There is problem in saving the event.       Please try again."));
             }
         }
     }
     else
     {
         return(View(calendarevent));
     }
 }
Esempio n. 2
0
        // PUT api/Event/5
        public IHttpActionResult PutCalendarEvent(int id, CalendarEvent calendarevent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            using (EventOrganizerEntities eventOrganizerEntities = new EventOrganizerEntities())
            {
                try
                {
                    eventOrganizerEntities.Entry(calendarevent).State = EntityState.Modified;
                    eventOrganizerEntities.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CalendarEventExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     using (EventOrganizerEntities db = new EventOrganizerEntities())
     {
         CalendarEvent calendarevent = db.CalendarEvents.Find(id);
         db.CalendarEvents.Remove(calendarevent);
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 private bool DeleteTitleType(int Id)
 {
     using (EventOrganizerEntities db = new EventOrganizerEntities())
     {
         var item = db.EventTypeOnes.Where(x => x.Id == Id).FirstOrDefault();
         if (item != null)
         {
             item.IsDeleted = true;
             db.SaveChanges();
         }
     }
     return(false);
 }
 public ActionResult Edit([Bind(Include = "Id,EventTitle,Abstract,EventDescription,StartDate,EndDate,Location,Url,Price,EventGroupTitle,EventGroupName,EventTypeOne,CreatedDateTime,LastUpdateDateTime,IsDeleted")] CalendarEvent calendarevent)
 {
     if (ModelState.IsValid)
     {
         using (EventOrganizerEntities db = new EventOrganizerEntities())
         {
             db.Entry(calendarevent).State = EntityState.Modified;
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     return(View(calendarevent));
 }
Esempio n. 6
0
        public IHttpActionResult PostCalendarEvent(CalendarEvent calendarevent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            using (EventOrganizerEntities eventOrganizerEntities = new EventOrganizerEntities())
            {
                eventOrganizerEntities.CalendarEvents.Add(calendarevent);
                eventOrganizerEntities.SaveChanges();
            }

            return(CreatedAtRoute("DefaultApi", new { id = calendarevent.Id }, calendarevent));
        }
 private void EditTitleType(string titleType, int id)
 {
     if (!string.IsNullOrEmpty(titleType))
     {
         using (EventOrganizerEntities db = new EventOrganizerEntities())
         {
             var item = db.EventTypeOnes.Where(x => x.Id == id).FirstOrDefault();
             db.Usp_UpdateCalendarEvents(titleType, item.EventTypeName, (int)Purpose.EditType);
             if (item != null)
             {
                 item.EventTypeName = titleType;
                 db.SaveChanges();
             }
         }
     }
 }
 private void EditGroupTitle(string groupTitle, int id)
 {
     if (!string.IsNullOrEmpty(groupTitle))
     {
         using (EventOrganizerEntities db = new EventOrganizerEntities())
         {
             var item = db.EventGroupTitles.Where(x => x.Id == id).FirstOrDefault();
             db.Usp_UpdateCalendarEvents(groupTitle, item.Title, (int)Purpose.EditGroupTitle);
             if (item != null)
             {
                 item.Title = groupTitle;
                 db.SaveChanges();
             }
         }
     }
 }
 private void AddTitleType(string name)
 {
     using (EventOrganizerEntities db = new EventOrganizerEntities())
     {
         var item = db.EventTypeOnes.Where(x => x.EventTypeName == name).FirstOrDefault();
         if (item == null)
         {
             EventTypeOne obj = new EventTypeOne();
             obj.EventTypeName      = name;
             obj.IsDeleted          = false;
             obj.CreatedDateTime    = DateTime.UtcNow;
             obj.LastUpdateDateTime = DateTime.UtcNow;
             db.EventTypeOnes.Add(obj);
             db.SaveChanges();
         }
     }
 }
Esempio n. 10
0
        public IHttpActionResult DeleteCalendarEvent(int id)
        {
            CalendarEvent calendarevent;

            using (EventOrganizerEntities eventOrganizerEntities = new EventOrganizerEntities())
            {
                calendarevent = eventOrganizerEntities.CalendarEvents.Find(id);
                if (calendarevent == null)
                {
                    return(NotFound());
                }
                else
                {
                    eventOrganizerEntities.CalendarEvents.Remove(calendarevent);
                    eventOrganizerEntities.SaveChanges();
                }
            }
            return(Ok(calendarevent));
        }
 private void AddGroupName(string name)
 {
     if (!string.IsNullOrEmpty(name))
     {
         using (EventOrganizerEntities db = new EventOrganizerEntities())
         {
             var item = db.EventGroupNames.Where(x => x.GroupName == name).FirstOrDefault();
             if (item == null)
             {
                 EventGroupName obj = new EventGroupName();
                 obj.GroupName          = name;
                 obj.IsDeleted          = false;
                 obj.CreatedDateTime    = DateTime.UtcNow;
                 obj.LastUpdateDateTime = DateTime.UtcNow;
                 db.EventGroupNames.Add(obj);
                 db.SaveChanges();
             }
         }
     }
 }