Exemplo n.º 1
0
        public async Task <HttpResponseMessage> RequestResetPassword(string userName)
        {
            IdentityUser user = await _userManager.FindByNameAsync(userName);

            if (user == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "User does not exist."));
            }

            string code = await _userManager.GeneratePasswordResetTokenAsync(user.Id);

            string callbackUrl = LocalUrlHelper.GenerateResetPasswordLink(user.Id.ToString(),
                                                                          HttpUtility.UrlEncode(code));

            Email email = new Email
            {
                Subject    = EmailSubject,
                Body       = $"Please reset your password by clicking <a href='{callbackUrl}'>here</a>",
                IsBodyHtml = true
            };

            email.To.Add(userName);
            _emailService.SendEmail(email);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        public DeepZoomLinkTableDto GetDeepZoomLinks(DeepZoomLinkDataTableFilterModelDto deepZoomLinkDataTableFilter)
        {
            var filterCriteria = _mapper.Map <DeepZoomLinkQuery>(deepZoomLinkDataTableFilter);

            IPagedList <DeepZoomRowDto> deepZoomLinks = _deepZoomLinkService.GetForNodePaged(
                filterCriteria.Id,
                filterCriteria.Type,
                filterCriteria,
                deepZoomLinkDataTableFilter.ExcludeDeepZoomLinkId,
                deepZoomLinkDataTableFilter.IsCompareToSameBlade);

            List <DeepZoomLinkTableRowDto> deepZoomLinkTableRows =
                _mapper.Map <IEnumerable <DeepZoomLinkTableRowDto> >(deepZoomLinks).ToList();

            deepZoomLinkTableRows.ForEach(row =>
            {
                row.Url = LocalUrlHelper.GenerateUrlForApi(
                    row.Country,
                    row.Site,
                    row.TurbineSerialNumber,
                    row.Blade, row.Surface, row.Inspection);
            });

            return(new DeepZoomLinkTableDto
            {
                DeepZoomLinkTableRows = deepZoomLinkTableRows,
                TotalDisplayedRecords = deepZoomLinks.TotalCount,
                TotalRecords = deepZoomLinks.TotalCount,
            });
        }
Exemplo n.º 3
0
        public HttpResponseMessage EditFinding(DefectChangeLog finding)
        {
            Defect      defect    = _defectService.FindById(finding.Id);
            List <Guid> defectIds = new List <Guid>();

            defectIds.Add(defect.Id);
            if (defect != null)
            {
                defect.Severity = finding.NewSeverity.HasValue ? finding.NewSeverity : finding.OriginalSeverity;
                defect.Name     = finding.NewType.HasValue ? finding.NewType.GetDescription() : finding.OriginalType.GetDescription();
                defect.Layer    = finding.NewLayer.HasValue ? finding.NewLayer.Value : finding.OriginalLayer;

                var result = _defectService.Update(defect);
                _defectService.ChangeDataQualityForSelectedFinding(defectIds);

                if (result.Succeeded)
                {
                    finding.DefectId    = defect.Id;
                    finding.NewLayer    = finding.NewLayer.HasValue ? finding.NewLayer : null;
                    finding.NewSeverity = finding.NewSeverity.HasValue ? finding.NewSeverity : null;
                    finding.NewType     = finding.NewType.HasValue ? finding.NewType : null;

                    var url = LocalUrlHelper.GenerateUrlEditedFinding(defect);
                    if (_defectChangeLogService.AddDefectChangeLog(finding).Succeeded)
                    {
                        _defectChangeLogService.Notify(finding, url);
                    }
                }

                return(result.Succeeded
                    ? Request.CreateResponse(HttpStatusCode.OK)
                    : Request.CreateErrorResponse(HttpStatusCode.BadRequest, result.Message));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, "Cannot find finding"));
        }
Exemplo n.º 4
0
        public async Task <HttpResponseMessage> RequestLoginAccess(RequestAccessDto user)
        {
            if (ModelState.IsValid)
            {
                IdentityUser  applicationUser = _mapper.Map <IdentityUser>(user);
                ServiceResult result          = await _userManagementService.RequestLoginAccess(applicationUser, user.Password);

                if (result.Succeeded)
                {
                    _userManagementService.SendNotificationEmail($"{user.FirstName} {user.LastName}", user.UserName,
                                                                 LocalUrlHelper.GetApplicationUrl());
                }

                return(Request.CreateResponse(HttpStatusCode.OK, result.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.BadRequest,
                                          string.Join("; ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage))));
        }
Exemplo n.º 5
0
        public async Task <HttpResponseMessage> Create()
        {
            HttpRequest httpRequest          = HttpContext.Current.Request;
            string      id                   = httpRequest.Params["id"];
            string      category             = httpRequest.Params["category"];
            string      type                 = httpRequest.Params["type"];
            string      description          = httpRequest.Params["description"];
            string      fileName             = httpRequest.Params["fileName"];
            string      notificationOfStatus = httpRequest.Params["notificationOfStatus"];
            string      route                = httpRequest.Params["link"];
            string      url                  = LocalUrlHelper.GetApplicationUrl() + route;

            if (description == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Not all params are defined"));
            }

            Feedback feedback = new Feedback
            {
                Id                   = id.HasValue() ? new Guid(id) : Guid.Empty,
                Type                 = (FeedbackType)Enum.Parse(typeof(FeedbackType), type, true),
                Category             = (FeedbackCategory)Int32.Parse(category),
                Description          = description,
                FileName             = fileName.HasValue() ? fileName : null,
                NotificationOfStatus = notificationOfStatus != "undefined" && bool.Parse(notificationOfStatus),
                Url                  = url
            };

            ServiceResult result = await _feedbackService.AddFeedback(feedback, httpRequest.Files.Count > 0?httpRequest.Files[0].InputStream : null);

            if (result.Succeeded)
            {
                result = _feedbackService.Notify(feedback);
            }

            return(result.Succeeded
                ? Request.CreateResponse(HttpStatusCode.OK)
                : Request.CreateErrorResponse(HttpStatusCode.BadRequest, result.Message));
        }
Exemplo n.º 6
0
        private void SendAllowAccessEmail(User user)
        {
            Email email = new Email();

            email.To.Add(user.Email);
            email.Subject    = "HermesOnline - Access Request Was Approved";
            email.IsBodyHtml = true;

            string applicationUrl = LocalUrlHelper.GetApplicationUrl();

            string htmlTextMessage = "<!DOCTYPE html>" +
                                     "<html>" +
                                     "<head></head>" +
                                     "<body>" +
                                     $"<p>Dear {user.Email},<br/> You now have access to <a href='{applicationUrl}'> Hermes </a>. There are 3 types of user on Hermes with different access levels to Hermes features.<br/> Find more details about access levels and related trainings on <a href='https://workspace.wp.siemens.com/communities/10011362/SitePages/About%20Hermes.aspx'> Hermes support page. </a> <br/> Best regards, <br/> The Hermes team. </p>" +
                                     "</body>" +
                                     "</html>";

            email.Body = htmlTextMessage;

            _emailService.SendEmail(email);
        }