Ejemplo n.º 1
0
        public Result Add([FromForm] ScheduleReply model)
        {
            Result result = Check(model);

            if (result.Succeed)
            {
                result = _scheduleReplyBusiness.Add(model);
            }
            return(result);
        }
Ejemplo n.º 2
0
        private static string GetReply(ScheduleReply reply)
        {
            if (reply.lessons.Length == 0)
            {
                return("Сегодня пар больше нет :-)");
            }
            var scheduleNextDay = new StringBuilder();

            foreach (var item in reply.lessons)
            {
                scheduleNextDay.Append(item);
                scheduleNextDay.Append("\n");
            }

            return(scheduleNextDay.Length == 0 ? null : scheduleNextDay.ToString());
        }
Ejemplo n.º 3
0
        public void SendMessage(BotUser user, Application.Reply reply)
        {
            var currentCommand = DefineCommand(user);
            var message        = reply switch
            {
                ScheduleReply s => GetReply(s),
                LessonReply l => GetLessonReply(l),
                LinksReply s => GetLinksReply(s),
                _ => null,
            };

            if (message != null)
            {
                vkMessageSender.SendNotification(user, message, currentCommand.GetKeyboard());
            }
        }
Ejemplo n.º 4
0
 private Result Check(ScheduleReply model)
 {
     if (model.Id > 0)
     {
         return(Result.Fail("添加操作的主键必须为0"));
     }
     if (model.ScheduleId <= 0)
     {
         return(Result.Fail("日程数据无效"));
     }
     if (model.EmployeeId <= 0)
     {
         return(Result.Fail("回复人信息丢失,请重新登录"));
     }
     if (string.IsNullOrWhiteSpace(model.EmployeeName))
     {
         return(Result.Fail("回复人信息丢失,请重新登录"));
     }
     if (string.IsNullOrWhiteSpace(model.Reply))
     {
         return(Result.Fail("请输入回复内容"));
     }
     return(Result.Success("成功"));
 }