Exemplo n.º 1
0
        public ActionResult Create(string code = null, int hour = -1, int day = -1, int month = -1, int year = -1, int idCar = -1, int idStudent = -1, int idTeacher = -1)
        {
            if (code == null || code == "" || hour < 1 || hour > 4 || day < 1 || day > 30 || month < 1 || month > 12 || year < 2016 || year > 2019 || idCar < 0 || idStudent < 0 || idTeacher < 0)
            {
                ModelState.AddModelError("error", "ERROR!");
            }
            else
            {
                var result = scheduleService.AddSchedule(code, hour, day, month, year, idCar, idStudent, idTeacher);
                if (result == 0)
                {
                    ModelState.AddModelError("error", "Add OK!");
                }
                else if (result == 1)
                {
                    ModelState.AddModelError("error", "Duplicate!");
                }
                else
                {
                    ModelState.AddModelError("error", "ERROR!");
                }
            }

            return(Find(null, hour, day, month, year, 0, 0, 0));
        }
Exemplo n.º 2
0
 public bool AddSchedule(SQLAdmin.Domain.Schedule schedule)
 {
     using (ChannelFactory <IScheduleService> channelFactory = new ChannelFactory <IScheduleService>("SQLAdmin.Timer"))
     {
         try
         {
             IScheduleService proxy = channelFactory.CreateChannel();
             SQLAdmin.TimerContract.Schedule entitySchedule = schedule.ToEntity();
             Monitor monitor = MonitorTypeHelper.GetMonitorByType(schedule.MonitorType);
             entitySchedule.Type     = monitor.Type;
             entitySchedule.Method   = monitor.Method;
             entitySchedule.Assembly = monitor.Assembly;
             monitor.Threshold       = schedule.Threshold;
             monitor.ToEmail         = schedule.ToEmail;
             monitor.DBConnect       = this.mDBConnect;
             entitySchedule.Context  = SerializerHelper.SerializerObjectByJsonConvert(monitor);
             return(proxy.AddSchedule(entitySchedule));
         }
         catch (Exception e)
         {
             throw;
         }
     }
 }
        public IActionResult AddNewScheduleForLecturer([FromBody] LecturerScheduleDto lecturerSchduleDto)
        {
            var scheduleId = _scheduleService.AddSchedule(lecturerSchduleDto);

            return(CreatedAtAction(nameof(GetScheduleById), new { id = scheduleId }, scheduleId));
        }
Exemplo n.º 4
0
 public void Post([FromBody] Schedule value)
 {
     scheduleService.AddSchedule(value);
 }