예제 #1
0
        public ActionResult Add(Tasks add, string start_time, string end_time)
        //public ActionResult Add( collection)
        {
            Tasks newEvent = new Tasks();

            newEvent.title = add.title;  //users.first_name;

            //newEvent.location   =  add.location; //users.last_name;

            newEvent.start_date = add.start_date;  //users.email;

            if (start_time != null)
            {
                newEvent.start_time = DateTime.Parse(start_time).TimeOfDay; //(TimeSpan)start_time;
            }
            else
            {
                newEvent.start_time = null;
            }

            if (end_time != null)
            {
                newEvent.end_time = DateTime.Parse(end_time).TimeOfDay; //(TimeSpan)end_time;
            }
            else
            {
                newEvent.end_time = null;
            }

            if (newEvent.start_time == null && newEvent.end_time == null)
            {
                newEvent.isTimeSet = 0;
            }
            else
            {
                newEvent.isTimeSet = 1;
            }

            newEvent.end_date = add.end_date;

            //addEvent.start_date =  add.all_time  ;
            newEvent.description = add.description;

            newEvent.priority = add.priority;

            string user_id = string.Empty;

            user_id = Convert.ToString(Session["user_id"]);

            if (newEvent.AddEvent(user_id, newEvent) == 1)
            {
                Tasks EditEvent = new Tasks();

                int event_id = EditEvent.GetLastId();

                returnEvent returnData = new returnEvent();

                var data = EditEvent.EditEvent(event_id);


                var returnData1 = new addedEvent {
                    success = 1, returnMsg = "Event Created SuccessFully", eventData = data
                };
                List <addedEvent> listAddedEvent = new List <addedEvent>();
                listAddedEvent.Add(returnData1);

                return(Json(listAddedEvent, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var returnData = new addedEvent {
                    success = 0, returnMsg = "Event Not Created SuccessFully"
                };
                List <addedEvent> listAddedEvent = new List <addedEvent>();
                listAddedEvent.Add(returnData);

                return(Json(listAddedEvent, JsonRequestBehavior.AllowGet));
            }
            //var addedEvent = { };
            //return View();// Json(addedEvent, JsonRequestBehavior.AllowGet);
        }