Ejemplo n.º 1
0
        public JsonResult QuickAddPersonalCal(FormCollection form)
        {
            JsonReturnMessages r            = new JsonReturnMessages();
            string             subject      = form["CalendarTitle"];
            string             strStartTime = form["CalendarStartTime"];
            string             strEndTime   = form["CalendarEndTime"];
            string             isallday     = form["IsAllDayEvent"];
            int      clientzone             = Convert.ToInt32(form["timezone"]);
            int      serverzone             = TimeHelper.GetTimeZone();
            var      zonediff = serverzone - clientzone;
            DateTime st;
            DateTime et;

            bool a = DateTime.TryParse(strEndTime, out et);
            bool b = DateTime.TryParse(strStartTime, out st);

            if (!b)
            {
                r.IsSuccess = false;
                r.Msg       = this.Resource("lang,notvoliddatetimeformat") + ":" + strStartTime;
                return(Json(r));
            }
            if (!a)
            {
                r.IsSuccess = false;
                r.Msg       = this.Resource("lang,notvoliddatetimeformat") + ":" + strEndTime;
                return(Json(r));
            }

            try
            {
                Calendar entity = new Calendar();
                entity.CalendarType  = 1;
                entity.InstanceType  = 0;
                entity.Subject       = subject;
                entity.StartTime     = st.AddHours(zonediff);
                entity.EndTime       = et.AddHours(zonediff);
                entity.IsAllDayEvent = isallday == "1";
                entity.UPAccount     = UserId;
                entity.UPName        = this.Resource("lang,admin");
                entity.UPTime        = DateTime.Now;
                entity.MasterId      = clientzone;
                r.Data      = _service.AddCalendar(entity);
                r.IsSuccess = true;
                r.Msg       = this.Resource("lang,successmsg");
            }
            catch (Exception ex)
            {
                r.IsSuccess = false;
                r.Msg       = ex.Message;
            }
            return(Json(r));
        }
 public IActionResult AddCalendar([FromBody] Calendar calendar)
 {
     int.TryParse(User.Identity.Name, out int userId);
     calendar.OwnerId = userId;
     if (_eventService.AddCalendar(calendar))
     {
         return(Ok(calendar));
     }
     return(BadRequest("There is something wrong with calendar info"));
 }
Ejemplo n.º 3
0
        public ActionResult <CalendarAddViewModel> AddCalendar(CalendarAddViewModel calendar)
        {
            CalendarAddViewModel calendarAdd = new CalendarAddViewModel();

            try
            {
                calendarAdd = _calendarService.AddCalendar(calendar);
            }
            catch (Exception es)
            {
                calendarAdd._failure = true;
                calendarAdd._message = es.Message;
            }
            return(calendarAdd);
        }
        public async Task <ActionResult> Add(long userId, [FromBody] CalendarViewModel calendarViewModel)
        {
            await calendarService.AddCalendar(userId, calendarViewModel);

            return(Ok());
        }
Ejemplo n.º 5
0
 public static int AddCalendar(Calendar cal)
 {
     return(calendar.AddCalendar(cal));
 }