コード例 #1
0
ファイル: CMController.cs プロジェクト: zxmajunhong/wanghai
        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));
        }
コード例 #2
0
 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"));
 }
コード例 #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);
        }
コード例 #4
0
        public async Task <ActionResult> Add(long userId, [FromBody] CalendarViewModel calendarViewModel)
        {
            await calendarService.AddCalendar(userId, calendarViewModel);

            return(Ok());
        }
コード例 #5
0
ファイル: CalendarManager.cs プロジェクト: 262734254/OA
 public static int AddCalendar(Calendar cal)
 {
     return(calendar.AddCalendar(cal));
 }