Beispiel #1
0
 public bool SaveComment(SaveCommentModel model,RequestTypeEnum type)
 {
     try
     {
         User user = UserDao.Load(AuthenticationService.CurrentUser.Id);
         switch (type)
         {
             case RequestTypeEnum.Appointment:
                 Appointment entity = AppointmentDao.Load(model.DocumentId);
                 AppointmentComment comment = new AppointmentComment
                                                  {
                                                      Comment = model.Comment,
                                                      Appointment = entity,
                                                      DateCreated = DateTime.Now,
                                                      User = user,
                                                  };
                 AppointmentCommentDao.MergeAndFlush(comment);
                 break;
             case RequestTypeEnum.AppointmentReport:
                 AppointmentReport rep = AppointmentReportDao.Load(model.DocumentId);
                 AppointmentReportComment comm = new AppointmentReportComment
                 {
                     Comment = model.Comment,
                     AppointmentReport = rep,
                     DateCreated = DateTime.Now,
                     User = user,
                 };
                 AppointmentReportCommentDao.MergeAndFlush(comm);
                 break;
             default:
                 throw new ValidationException(string.Format(StrInvalidCommentType,(int)type));
         }
         return true;
     }
     catch (Exception ex)
     {
         AppointmentCommentDao.RollbackTran();
         Log.Error("Exception", ex);
         model.Error = StrException + ex.GetBaseException().Message;
         return false;
     }
 }