예제 #1
0
        public async Task <IActionResult> AddReport(ReportAddViewModel model)
        {
            if (ModelState.IsValid)
            {
                _reportService.Save(new Report()
                {
                    TaskId      = model.TaskId,
                    Detail      = model.Detail,
                    Description = model.Definition
                });
                var activeuser = await _userManager.FindByNameAsync(User.Identity.Name);

                var adminlist = await _userManager.GetUsersInRoleAsync("Admin");

                foreach (var admin in adminlist)
                {
                    _noticeService.Save(new Notice
                    {
                        Description = $"{activeuser.Name} {activeuser.SurName} yeni bir rapor yazdı",
                        AppUserId   = admin.Id,
                    });
                }


                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
예제 #2
0
        public IActionResult AddReport(int id)
        {
            var job = _JobService.GetJobsWithUrgencyByID(id);
            ReportAddViewModel model = new ReportAddViewModel();

            model.JobId = id;
            model.Job   = job;
            return(View(model));
        }
예제 #3
0
        public IActionResult AddReport(int id)
        {
            TempData["Active"] = "workorder";
            var task = _taskService.GetUrgencyId(id);
            ReportAddViewModel model = new ReportAddViewModel();

            model.TaskId = id;
            model.Tasks  = task;
            return(View(model));
        }
        public Report PrepareReportEntity(ReportAddViewModel reportAddViewModel = null)
        {
            if (reportAddViewModel == null)
            {
                throw new ArgumentNullException(nameof(reportAddViewModel));
            }

            var report = _mapper.Map <Report>(reportAddViewModel);

            return(report);
        }
예제 #5
0
 public IActionResult AddReport(ReportAddViewModel model)
 {
     if (ModelState.IsValid)
     {
         _ReportService.Save(new Report()
         {
             JobId       = model.JobId,
             Detail      = model.Detail,
             Description = model.Description
         });
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
예제 #6
0
        public IActionResult EditReport(ReportAddViewModel reportAddViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(reportAddViewModel));
            }

            var report = _reportService.GetById(reportAddViewModel.Id);

            if (report == null)
            {
                return(RedirectToAction(nameof(AssignedWork)));
            }

            report = _reportModelFactory.PrepareReportEntity(reportAddViewModel);
            _reportService.Update(report);

            return(RedirectToAction(nameof(AssignedWork)));
        }
예제 #7
0
        public async Task <IActionResult> CreateReport(ReportAddViewModel reportAddViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(reportAddViewModel));
            }

            var report = _reportModelFactory.PrepareReportEntity(reportAddViewModel);

            _reportService.Insert(report);

            var currentUser = await CurrentUser();

            var administrators = await _userManager.GetUsersInRoleAsync("Admin");

            _notificationService.SendNotificationsManagers(currentUser, "yeni bir rapor yazdı.", administrators.ToList());

            return(RedirectToAction(nameof(AssignedWork)));
        }
        public ReportAddViewModel PrepareReportAddViewModel(Assignment assignment = null, Report report = null)
        {
            var reportAddViewModel = new ReportAddViewModel();

            if (report != null)
            {
                reportAddViewModel.Id                           = report.Id;
                reportAddViewModel.Detail                       = report.Detail;
                reportAddViewModel.Definition                   = report.Definition;
                reportAddViewModel.AssignmentId                 = report.AssignmentId;
                reportAddViewModel.AssignmentName               = report.Assignment.Name;
                reportAddViewModel.AssignmentDescription        = report.Assignment.Description;
                reportAddViewModel.AssignmentExigencyDefinition = report.Assignment.Exigency.Definition;

                return(reportAddViewModel);
            }

            reportAddViewModel.AssignmentId                 = assignment.Id;
            reportAddViewModel.AssignmentName               = assignment.Name;
            reportAddViewModel.AssignmentDescription        = assignment.Description;
            reportAddViewModel.AssignmentExigencyDefinition = assignment.Exigency.Definition;

            return(reportAddViewModel);
        }