Exemplo n.º 1
0
        //public JobBLL(IJobRepository jobRepository, IStakeHolderRepository stakeHolderRepository,ITakerRepository takerRepository)
        //{
        //    _jobRepository = jobRepository;
        //    _stakeHolderRepository = stakeHolderRepository;
        //    _takerRepository = takerRepository;
        //}

        public Job CreateJob(ReportRequestViewModel requestViewModel)
        {
            var stakeHolder = _stakeHolderRepository.GetStakeHolderById(requestViewModel.StakeHolderId);
            var user        = _userRepository.GetAllUsers().SingleOrDefault(d => d.UserType == UserType.StakeHolder && d.TargetUserID == requestViewModel.StakeHolderId);
            var job         = new Job
            {
                JobTitle          = requestViewModel.JobTitle,
                JobDescription    = requestViewModel.JobDescription,
                JobCategory       = requestViewModel.JobType,
                CreatedOn         = DateTime.Now,
                UpdatedOn         = DateTime.Now,
                ReportedById      = stakeHolder.ClientId,
                CreatedById       = user.UserId,
                JobPriority       = requestViewModel.JobPriority,
                EstimatedTimeHour = requestViewModel.EstimatedTimeInHours,
                ReleaseVersion    = requestViewModel.ReleaseVersion
            };

            if (requestViewModel.JobTakerId != 0)
            {
                job.AssignedToId = requestViewModel.JobTakerId;
                job.Status       = JobStatus.Assigned;
            }
            else
            {
                job.Status = JobStatus.New;
            }

            return(_jobRepository.Create(job));
        }
Exemplo n.º 2
0
        public ActionResult ProcessRequest(ReportRequestViewModel reportRequest)
        {
            if (ModelState.IsValid)
            {
                var job = _jobBLL.CreateJob(reportRequest);

                if (reportRequest.Files != null)
                {
                    foreach (var file in reportRequest.Files)
                    {
                        if (file != null)
                        {
                            var fileName      = _fileBLL.GetFileName(file.FileName);
                            var jobFolderPath = _fileBLL.GetFolderPath(job.JobId);

                            if (!(Directory.Exists(jobFolderPath)))
                            {
                                Directory.CreateDirectory(jobFolderPath);
                            }

                            file.SaveAs(Path.Combine(string.Format("{0}\\{1}", jobFolderPath, fileName)));
                            ViewBag.UploadStatus = reportRequest.Files.Count().ToString() + "Files Uploaded Successfully";
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Fill in all the fields");
            }
            return(View(reportRequest));
        }
Exemplo n.º 3
0
 public List<ReportRequestViewModel> GetRequestPlaces()
 {
     var flowers = flowerLogic.Read(null);
     var requests = requestLogic.Read(null);
     var list = new List<ReportRequestViewModel>();
     foreach (var request in requests)
     {
         var record = new ReportRequestViewModel
         {
             RequestName = request.RequestName,
             Flowers = new List<Tuple<string, int>>(),
             TotalCount = 0
         };
         foreach (var place in flowers)
         {
             if (request.RequestsFlowers.ContainsKey(place.Id))
             {
                 record.Flowers.Add(new Tuple<string, int>(place.FlowerName,
                request.RequestsFlowers[place.Id].Item2));
                 record.TotalCount +=
                request.RequestsFlowers[place.Id].Item2;
             }
         }
         list.Add(record);
     }
     return list;
 }
Exemplo n.º 4
0
        public async Task <ReportResponseViewModel> GetProjectDeploymentCountsAsync(ReportRequestViewModel request)
        {
            using (var connection = new SqlConnection(MetricConfiguration.ConnectionString))
            {
                return(new ReportResponseViewModel
                {
                    Data = await connection.QueryAsync <ReportResponseDataViewModel>(
                        @"SELECT COUNT(*) AS [Count],
	                                p.Name Label
                            FROM dbo.Deployment d
	                            INNER JOIN dbo.Environment e
		                            ON d.EnvironmentId = e.Id
	                            INNER JOIN dbo.Release r
		                            ON d.ReleaseId = r.Id
	                            INNER JOIN dbo.Project p
		                            ON r.ProjectId = p.Id
	                            INNER JOIN dbo.Space s
		                            ON p.SpaceId = s.Id
	                            LEFT JOIN dbo.tenant t
		                            ON d.TenantId = t.Id
                            WHERE d.StartTime BETWEEN @StartDate AND @EndDate
                                and Isnull(@spaceId, s.id) = s.Id
                            GROUP BY p.Name
	                        ORDER BY COUNT(*) desc"    ,
                        new
                    {
                        StartDate = request.StartDate,
                        EndDate = request.EndDate.AddDays(1).AddSeconds(-1),
                        SpaceId = request.SpaceId <= 0 ? null : (int?)request.SpaceId
                    })
                });
            }
        }
Exemplo n.º 5
0
        public ActionResult ProcessRequest(int stakeHolderId, string stakeHolderOrganization)
        {
            var model = new ReportRequestViewModel();

            model.StakeHolderId           = stakeHolderId;
            model.StakeHolderOrganization = stakeHolderOrganization;
            model.JobStatus = Req.Enums.JobStatus.New;
            ViewBag.Takers  = _takerBLL.GetTakers();
            return(View(model));
        }
Exemplo n.º 6
0
        //public JobController(IJobBLL jobBLL)
        //{
        //    _jobBLL = jobBLL;
        //}
        // GET: Job

        public ActionResult CreateJob(ReportRequestViewModel reportRequest)
        {
            if (ModelState.IsValid)
            {
                var job = _jobBLL.CreateJob(reportRequest);
                //var queueInstance = JobQueueService.GetInstance();
                //queueInstance.Enqueue(job);
            }
            else
            {
                ModelState.AddModelError("", "Fill in all the fields");
            }
            var stakeHolder = _stakeHolderBLL.GetStakeHolderById(reportRequest.StakeHolderId);

            return(RedirectToAction("index", "ReportRequest", new RouteValueDictionary(stakeHolder)));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> GetAllTransactionBetween(ReportRequestViewModel reportRequestViewModel)
        {
            try
            {
                var transactions = await _transactionRepository.Get(x => x.AddedAt >= reportRequestViewModel.From && x.AddedAt <= reportRequestViewModel.To && x.Validated && x.To == reportRequestViewModel.InternalName);

                return(Ok(transactions.Select(x => x.ToTransactionResponseViewModel())));
            }
            catch (Exception)
            {
                return(BadRequest(new ErrorResponseViewModel()
                {
                    Id = (int)ErrorResponseIds.InvalidTransaction, Message = "Error"
                }));
            }
        }
Exemplo n.º 8
0
 public Task <ReportResponseViewModel> GetEnvironmentDeploymentCounts(ReportRequestViewModel request)
 {
     return(_reportingRepository.GetEnvironmentDeploymentCountsAsync(request));
 }