コード例 #1
0
        public IActionResult Create([FromForm] CreateReport model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!model.File.FileName.ToLower().EndsWith("pdf"))
            {
                return(BadRequest(ResponseMessage.IncorrectFileExtension));
            }
            string fileId = Guid.NewGuid().ToString();

            var record = new Domain.Models.Reports();

            record.Date      = DateTime.Now;
            record.SubjectId = model.SubjectId;
            record.FileId    = fileId;
            record.FileName  = model.File.FileName;
            SaveFile(model.File, fileId);

            _reportsRepository.Add(record, model.StudentsIds);

            return(Ok());
        }
コード例 #2
0
 public IActionResult Add(ReportFormModel rep)
 {
     if (ModelState.IsValid)
     {
         var report = new EventReport
         {
             reportDescription         = rep.reportDescription,
             Approved                  = false,
             areaId                    = _areaRepo.getAreaByName(rep.areaName).AreaId,
             NocSubsQTYChange          = rep.NocSubsQTYChange,
             PHChange                  = rep.PHChange,
             PollutionPercentageChange = rep.PollutionPercentageChange,
             reporterUsername          = User.Identity.Name,
             ReportDate                = DateTime.Now.ToString("MM/dd/yyyy")
         };
         _reportRepo.Add(report);
         return(View("ReportAdded"));
     }
     return(View(new EventReport()));
 }