Ejemplo n.º 1
0
        public HttpResponseMessage AssignChecklistToQaAdvisor(Guid id, QaAdvisorViewModel model)
        {
            try
            {
                var checklist = _checklistRepository.GetById(id);

                if (checklist == null)
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound,
                        "Checklist: " + id + "Not Found."));
                }

                var qaAdvisor = _qaAdvisorRepository.GetById(model.Id);

                checklist.QaAdvisor = qaAdvisor;
                checklist.Status = "Assigned";

                //Save.
                _checklistRepository.SaveOrUpdate(checklist);
                _checklistRepository.Flush();


                var sendChecklistAssignedEmail = new SendChecklistAssignedEmail
                {
                    ChecklistId = id,
                    AssignedToId = model.Id
                };

                if (checklist.ClientId.HasValue)
                {
                    var clientDetail = _clientDetailsService.Get(checklist.ClientId.Value);

                    var site = checklist.SiteId.HasValue
                        ? _clientDetailsService.GetSite(checklist.ClientId.Value, checklist.SiteId.Value)
                        : null;

                    var postcode = site != null ? site.Postcode : "";

                    sendChecklistAssignedEmail.Can = clientDetail.CAN;
                    sendChecklistAssignedEmail.SiteName = site != null ? site.SiteName : "";
                    sendChecklistAssignedEmail.Address1 = site != null ? site.Address1 : "";
                    sendChecklistAssignedEmail.Address2 = site != null ? site.Address2 : "";
                    sendChecklistAssignedEmail.Address3 = site != null ? site.Address3 : "";
                    sendChecklistAssignedEmail.Address4 = site != null ? site.Address4 : "";
                    sendChecklistAssignedEmail.Address5 = site != null ? site.Address5 : "";
                    sendChecklistAssignedEmail.Postcode = postcode;
                }
                else
                {
                    sendChecklistAssignedEmail.Can = "Not specified";
                    sendChecklistAssignedEmail.Postcode = "Not specified";
                    ;
                }

                _bus.Send(sendChecklistAssignedEmail);
            }

            catch (Exception ex)
            {
                LogManager.GetLogger(typeof (ChecklistController)).Error(ex);
                throw;
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
Ejemplo n.º 2
0
        public void AssignChecklistToQaAdvisor(Checklist checklist, QaAdvisor qaAdvisor)
        {
            if (checklist.Status == Checklist.STATUS_SUBMITTED)
                return;

            if (checklist.QaAdvisor == null)
            {
                checklist.QaAdvisorAssignedOn = DateTime.Now;
            }

            checklist.QaAdvisor = qaAdvisor;
            checklist.Status = Checklist.STATUS_ASSIGNED;

            var sendChecklistAssignedEmail = new SendChecklistAssignedEmail
            {
                ChecklistId = checklist.Id,
                AssignedToId = qaAdvisor.Id
            };

            if (checklist.ClientId.HasValue)
            {
                var clientDetail = _clientDetailsService.Get(checklist.ClientId.Value);

                var site = checklist.SiteId.HasValue
                    ? _clientDetailsService.GetSite(checklist.ClientId.Value, checklist.SiteId.Value)
                    : null;

                var postcode = site != null ? site.Postcode : "";

                sendChecklistAssignedEmail.Can = clientDetail.CAN;
                sendChecklistAssignedEmail.SiteName = site != null ? site.SiteName : "";
                sendChecklistAssignedEmail.Address1 = site != null ? site.Address1 : "";
                sendChecklistAssignedEmail.Address2 = site != null ? site.Address2 : "";
                sendChecklistAssignedEmail.Address3 = site != null ? site.Address3 : "";
                sendChecklistAssignedEmail.Address4 = site != null ? site.Address4 : "";
                sendChecklistAssignedEmail.Address5 = site != null ? site.Address5 : "";
                sendChecklistAssignedEmail.Postcode = postcode;
            }
            else
            {
                sendChecklistAssignedEmail.Can = "Not specified";
                sendChecklistAssignedEmail.Postcode = "Not specified";
            }

            _bus.Send(sendChecklistAssignedEmail);
        }