Exemplo n.º 1
0
        public void CelLGapExists_Should_handle_null_prevCell()
        {
            var currCell = new ProfileCellData();

            Assert.IsFalse(ProfilesHelper.CellGapExists(null, currCell, out double prevStationIntercept));
            Assert.AreEqual(0.0, prevStationIntercept);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> AuthenticateInstagram()
        {
            int count = 0;

            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);

            try
            {
                count = Convert.ToInt32(profileCount);
            }
            catch (Exception ex)
            {
                TempData["Error"] = "Error while getting profile count.";
                return(RedirectToAction("Index", "Home"));
            }
            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);

            if (count >= MaxCount)
            {
                TempData["Error"] = "Max profile Count reached.";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                HttpContext.Session.SetObjectAsJson("Instagram", "Instagram_Account");
                string authUrl = _appSettings.InsagramAuthUrl + "&client_id=" + _appSettings.InstagramClientKey + "&redirect_uri=" + _appSettings.InstagramCallBackURL;
                return(Redirect(authUrl));
            }
        }
Exemplo n.º 3
0
        public void PD_PostProfileProductionDataFailed()
        {
            ProfileProductionDataRequest request = CreateRequest();
            MemoryStream raptorResult            = null;

            Assert.IsTrue(RaptorConverters.DesignDescriptor(request.AlignmentDesign).IsNull(), "A linear profile expected.");

            ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out TWGS84Point startPt, out var endPt, out bool positionsAreGrid);

            TASNodeServiceRPCVerb_RequestProfile_Args args
                = __Global.Construct_RequestProfile_Args
                      (request.ProjectId.Value,
                      -1, // don't care
                      positionsAreGrid,
                      startPt,
                      endPt,
                      RaptorConverters.ConvertFilter(request.Filter),
                      RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmAutomatic),
                      RaptorConverters.DesignDescriptor(request.AlignmentDesign),
                      request.ReturnAllPassesAndLayers);

            // Create the mock PDSClient with successful result...
            var mockRaptorClient = new Mock <IASNodeClient>();
            var mockLogger       = new Mock <ILoggerFactory>();
            var mockConfigStore  = new Mock <IConfigurationStore>();

            mockRaptorClient.Setup(prj => prj.GetProfile(It.IsAny <TASNodeServiceRPCVerb_RequestProfile_Args>() /*args*/)).Returns(raptorResult);

            // Create an executor...
            var executor = RequestExecutorContainerFactory.Build <ProfileProductionDataExecutor>(mockLogger.Object, mockRaptorClient.Object, configStore: mockConfigStore.Object);

            Assert.ThrowsExceptionAsync <ServiceException>(async() => await executor.ProcessAsync(request));
        }
Exemplo n.º 4
0
        public ActionResult Create(ProfilesEditViewModels model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here
                    var profiles = new ProfilesHelper();
                    var profile = new Profile()
                    {
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        Address = model.Address,
                        UserId = User.Identity.GetUserId(),
                        DOB = model.DoB,
                        GenderId = (int)model.Gender,
                        Telephone = model.Telephone
                    };

                    profiles.Add(profile);
                    return RedirectToAction("Details");
                }
                return View(model);
            }
            catch(Exception ex)
            {
                return View();
            }
        }
Exemplo n.º 5
0
        private async Task <CompactionProfileResult <CompactionProfileVertex> > PerformProductionDataProfilePostWithTRexGateway(CompactionProfileDesignRequest request)
        {
            ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out WGSPoint startPt, out var endPt, out bool positionsAreGrid);

            var designProfileRequest = new DesignProfileRequest(request.ProjectUid ?? Guid.Empty, request.DesignDescriptor?.FileUid ?? Guid.Empty, request.DesignDescriptor?.Offset ?? 0, startPt.Lon, startPt.Lat, endPt.Lon, endPt.Lat, positionsAreGrid);

            var trexResult = await trexCompactionDataProxy.SendDataPostRequest <DesignProfileResult, DesignProfileRequest>(designProfileRequest, "/profile/design", customHeaders);

            return(trexResult?.Code == ContractExecutionStatesEnum.ExecutedSuccessfully ? ConvertTRexProfileResult(trexResult) : null);
        }
Exemplo n.º 6
0
        private CompactionProfileResult <CompactionProfileCell> ProcessProductionDataWithRaptor(
            CompactionProfileProductionDataRequest request)
        {
            MemoryStream memoryStream;

            var filter              = RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient);
            var designDescriptor    = RaptorConverters.DesignDescriptor(request.CutFillDesignDescriptor);
            var alignmentDescriptor = RaptorConverters.DesignDescriptor(request.AlignmentDesign);
            var liftBuildSettings   =
                RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmNone);

            ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out var startPt, out var endPt,
                                                      out var positionsAreGrid);

            if (request.IsAlignmentDesign)
            {
                var args
                    = ASNode.RequestAlignmentProfile.RPC.__Global.Construct_RequestAlignmentProfile_Args
                          (request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                          ProfilesHelper.PROFILE_TYPE_NOT_REQUIRED,
                          request.StartStation ?? ValidationConstants3D.MIN_STATION,
                          request.EndStation ?? ValidationConstants3D.MIN_STATION,
                          alignmentDescriptor,
                          filter,
                          liftBuildSettings,
                          designDescriptor,
                          request.ReturnAllPassesAndLayers);

                memoryStream = raptorClient.GetAlignmentProfile(args);
            }
            else
            {
                var args
                    = ASNode.RequestProfile.RPC.__Global.Construct_RequestProfile_Args
                          (request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                          ProfilesHelper.PROFILE_TYPE_HEIGHT,
                          positionsAreGrid,
                          startPt,
                          endPt,
                          filter,
                          liftBuildSettings,
                          designDescriptor,
                          request.ReturnAllPassesAndLayers);

                memoryStream = raptorClient.GetProfile(args);
            }

            return(memoryStream != null?ConvertProfileResult(memoryStream, request.LiftBuildSettings) : null);
        }
Exemplo n.º 7
0
        public void CellGapExists(double prevStation, double prevInterceptLength, double currStation, bool expectedResult, double expectedPrevStationIntercept)
        {
            var prevCell = new ProfileCellData
            {
                Station         = prevStation,
                InterceptLength = prevInterceptLength
            };

            var currCell = new ProfileCellData
            {
                Station = currStation
            };

            Assert.AreEqual(expectedResult, ProfilesHelper.CellGapExists(prevCell, currCell, out double prevStationIntercept));
            Assert.AreEqual(expectedPrevStationIntercept, prevStationIntercept);
        }
Exemplo n.º 8
0
        private ProfileResult PerformProductionDataProfilePost(ProfileProductionDataRequest request)
        {
            MemoryStream memoryStream;

            if (request.IsAlignmentDesign)
            {
                var args = ASNode.RequestAlignmentProfile.RPC.__Global.Construct_RequestAlignmentProfile_Args(
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    ProfilesHelper.PROFILE_TYPE_NOT_REQUIRED,
                    request.StartStation ?? ValidationConstants3D.MIN_STATION,
                    request.EndStation ?? ValidationConstants3D.MIN_STATION,
                    RaptorConverters.DesignDescriptor(request.AlignmentDesign),
                    RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient),
                    RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmAutomatic),
                    RaptorConverters.DesignDescriptor(request.AlignmentDesign),
                    request.ReturnAllPassesAndLayers);

                memoryStream = raptorClient.GetAlignmentProfile(args);
            }
            else
            {
                ProfilesHelper.ConvertProfileEndPositions(
                    request.GridPoints,
                    request.WGS84Points,
                    out VLPDDecls.TWGS84Point startPt,
                    out VLPDDecls.TWGS84Point endPt,
                    out bool positionsAreGrid);

                var args = ASNode.RequestProfile.RPC.__Global.Construct_RequestProfile_Args(
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    ProfilesHelper.PROFILE_TYPE_NOT_REQUIRED,
                    positionsAreGrid,
                    startPt,
                    endPt,
                    RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient),
                    RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmAutomatic),
                    RaptorConverters.DesignDescriptor(request.AlignmentDesign),
                    request.ReturnAllPassesAndLayers);

                memoryStream = raptorClient.GetProfile(args);
            }

            return(memoryStream != null
        ? ConvertProfileResult(memoryStream, request.CallId ?? Guid.NewGuid())
        : null); // TODO: return appropriate result
        }
Exemplo n.º 9
0
        private CompactionProfileResult <CompactionProfileVertex> PerformProductionDataProfilePost(CompactionProfileDesignRequest request)
        {
            CompactionProfileResult <CompactionProfileVertex> result;

            try
            {
                ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out TWGS84Point startPt, out TWGS84Point endPt, out bool positionsAreGrid);

                var designProfile = DesignProfiler.ComputeProfile.RPC.__Global.Construct_CalculateDesignProfile_Args(
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    false,
                    startPt,
                    endPt,
                    ValidationConstants3D.MIN_STATION,
                    ValidationConstants3D.MAX_STATION,
                    RaptorConverters.DesignDescriptor(request.DesignDescriptor),
                    RaptorConverters.EmptyDesignDescriptor,
                    RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient),
                    positionsAreGrid);

                var memoryStream = raptorClient.GetDesignProfile(designProfile);

                if (memoryStream != null)
                {
                    result = ConvertProfileResult(memoryStream);
                    memoryStream.Close();
                }
                else
                {
                    //For convenience return empty list rather than null for easier manipulation
                    result = new CompactionProfileResult <CompactionProfileVertex> {
                        results = new List <CompactionProfileVertex>()
                    };
                }
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }

            return(result);
        }
Exemplo n.º 10
0
        public async Task <ActionResult> AddGoogleAccount(string Op)
        {
            int count = 0;

            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);

            try
            {
                count = Convert.ToInt32(profileCount);
            }
            catch (Exception ex)
            {
                TempData["Error"] = "Error while getting profile count.";
                return(RedirectToAction("Index", "Home"));
            }

            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);

            if (count >= MaxCount)
            {
                TempData["Error"] = "Max profile Count reached.";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (string.IsNullOrEmpty(Op))
                {
                    HttpContext.Session.SetObjectAsJson("Google", "Gplus_Account");
                    string googleurl = "https://accounts.google.com/o/oauth2/auth?client_id=" + _appSettings.GoogleConsumerKey + "&redirect_uri=" + _appSettings.GoogleRedirectUri + "&scope=https://www.googleapis.com/auth/youtube+https://www.googleapis.com/auth/youtube.readonly+https://www.googleapis.com/auth/youtubepartner+https://www.googleapis.com/auth/youtubepartner-channel-audit+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me&response_type=code&access_type=offline&approval_prompt=force";
                    return(Redirect(googleurl));
                }
                else
                {
                    HttpContext.Session.SetObjectAsJson("Google", "Ganalytics_Account");
                    string googleurl = "https://accounts.google.com/o/oauth2/auth?approval_prompt=force&access_type=offline&client_id=" + _appSettings.GoogleConsumerKey + "&redirect_uri=" + _appSettings.GoogleRedirectUri + "&scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/analytics+https://www.googleapis.com/auth/analytics.edit+https://www.googleapis.com/auth/analytics.readonly&response_type=code";
                    return(Redirect(googleurl));
                }
            }
        }
Exemplo n.º 11
0
        public async Task <ActionResult> AuthenticateLinkedin(string Op)
        {
            int    count = 0;
            Random ran   = new Random();
            int    x     = ran.Next(8976557);

            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);

            try
            {
                count = Convert.ToInt32(profileCount);
            }
            catch (Exception ex)
            {
                TempData["Error"] = "Error while getting profile count.";
                return(RedirectToAction("Index", "Home"));
            }

            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);

            if (count >= MaxCount)
            {
                TempData["Error"] = "Max profile Count reached.";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (string.IsNullOrEmpty(Op))
                {
                    HttpContext.Session.SetObjectAsJson("linSocial", "lin_Account");
                    return(Redirect("https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=" + _appSettings.LinkedinApiKey + "&redirect_uri=" + _appSettings.LinkedinCallBackURL + "&state=" + x.ToString() + "&?scope=r_basicprofile+w_share"));
                }
                else
                {
                    HttpContext.Session.SetObjectAsJson("linSocial", "lin_Page");
                    return(Redirect("https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=" + _appSettings.LinkedinApiKey + "&redirect_uri=" + _appSettings.LinkedinCallBackURL + "&state=" + x.ToString() + "&?scope=r_basicprofile+w_share+rw_company_admin"));
                }
            }
        }
Exemplo n.º 12
0
        // GET: Profiles/Details/5
        public ActionResult Details()
        {
            var user = User.Identity.GetUser(true);

            var profile = user.Profile;
            if (profile == null)
            {
                return RedirectToAction("Create", "Profile");
            }
            ProfilesDetailsViewModels model = new ProfilesDetailsViewModels()
            {
                FirstName = profile.FirstName,
                LastName = profile.LastName,
                Address = profile.Address,
                DoB = profile.DOB,
                Gender = (GenderType)Enum.ToObject(typeof(GenderType), profile.GenderId),
                Telephone = profile.Telephone
            };
            var profiles = new ProfilesHelper();
            profiles.Update(profile);
            return View(model);
        }
        public async Task <ActionResult> AddFacebookAcc(string Op)
        {
            int count = 0;

            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);

            try
            {
                count = Convert.ToInt32(profileCount);
            }
            catch (Exception ex)
            {
                TempData["Error"] = "Error while getting profile count.";
                return(RedirectToAction("Index", "Home"));
            }

            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);

            if (count >= MaxCount)
            {
                TempData["Error"] = "Max profile Count reached.";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (string.IsNullOrEmpty(Op))
                {
                    HttpContext.Session.SetObjectAsJson("fbSocial", "Fb_Account");
                }
                else
                {
                    HttpContext.Session.SetObjectAsJson("fbSocial", "Fb_Page");
                }
                return(Redirect(Socioboard.Facebook.Auth.Authentication.GetFacebookRedirectLink(_appSettings.FacebookAuthUrl, _appSettings.FacebookClientId, _appSettings.FacebookRedirectUrl)));
            }
        }
        public async Task <IActionResult> AddTwitterAccount(bool follow)
        {
            int count = 0;

            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);

            try
            {
                count = Convert.ToInt32(profileCount);
            }
            catch (Exception ex)
            {
                TempData["Error"] = "Error while getting profile count.";
                return(RedirectToAction("Index", "Home"));
            }
            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);

            if (count >= MaxCount)
            {
                TempData["Error"] = "Max profile Count reached.";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (follow)
                {
                    HttpContext.Session.SetObjectAsJson("Twitter", "Twitter_Account_Follow");
                }
                else
                {
                    HttpContext.Session.SetObjectAsJson("Twitter", "Twitter_Account");
                }
                OAuthCredentials credentials = new OAuthCredentials()
                {
                    Type              = OAuthType.RequestToken,
                    SignatureMethod   = OAuthSignatureMethod.HmacSha1,
                    ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                    ConsumerKey       = _appSettings.twitterConsumerKey,
                    ConsumerSecret    = _appSettings.twitterConsumerScreatKey,
                    CallbackUrl       = _appSettings.twitterRedirectionUrl
                };
                // Use Hammock to create a rest client
                var client = new RestClient
                {
                    Authority   = "https://api.twitter.com/oauth",
                    Credentials = credentials,
                };
                // Use Hammock to create a request
                var request = new RestRequest
                {
                    Path = "request_token"
                };
                // Get the response from the request
                var response   = client.Request(request);
                var collection = HttpUtility.ParseQueryString(response.Content);
                //string str = collection[1].ToString();
                //HttpContext.Current.Session["requestSecret"] = collection[1];
                string rest = "https://api.twitter.com/oauth/authorize?oauth_token=" + collection[0];
                HttpContext.Session.SetObjectAsJson("requestSecret", collection[1]);

                return(Redirect(rest));
            }
        }
Exemplo n.º 15
0
        private CompactionProfileResult <CompactionSummaryVolumesProfileCell> ProcessSummaryVolumesProfileCells(List <SummaryVolumeProfileCell> profileCells, double gridDistanceBetweenProfilePoints, VolumeCalcType calcType)
        {
            var profile = new CompactionProfileResult <CompactionSummaryVolumesProfileCell>();

            profile.results = new List <CompactionSummaryVolumesProfileCell>();
            SummaryVolumeProfileCell prevCell = null;

            foreach (var currCell in profileCells)
            {
                var gapExists = ProfilesHelper.CellGapExists(prevCell, currCell, out var prevStationIntercept);

                if (gapExists)
                {
                    var gapCell = new CompactionSummaryVolumesProfileCell(SumVolGapCell);
                    gapCell.station = prevStationIntercept;
                    profile.results.Add(gapCell);
                }

                var lastPassHeight1 = currCell.LastCellPassElevation1 == VelociraptorConstants.NULL_SINGLE
          ? float.NaN
          : currCell.LastCellPassElevation1;

                var lastPassHeight2 = currCell.LastCellPassElevation2 == VelociraptorConstants.NULL_SINGLE
        ? float.NaN
          : currCell.LastCellPassElevation2;

                var designHeight = currCell.DesignElev == VelociraptorConstants.NULL_SINGLE
        ? float.NaN
          : currCell.DesignElev;

                float cutFill = float.NaN;
                switch (calcType)
                {
                case VolumeCalcType.GroundToGround:
                    cutFill = float.IsNaN(lastPassHeight1) || float.IsNaN(lastPassHeight2)
              ? float.NaN
              : lastPassHeight2 - lastPassHeight1;
                    break;

                case VolumeCalcType.GroundToDesign:
                    cutFill = float.IsNaN(lastPassHeight1) || float.IsNaN(designHeight)
              ? float.NaN
              : designHeight - lastPassHeight1;
                    break;

                case VolumeCalcType.DesignToGround:
                    cutFill = float.IsNaN(designHeight) || float.IsNaN(lastPassHeight2)
              ? float.NaN
              : lastPassHeight2 - designHeight;
                    break;
                }

                profile.results.Add(new CompactionSummaryVolumesProfileCell
                {
                    cellType = prevCell == null ? ProfileCellType.MidPoint : ProfileCellType.Edge,

                    station = currCell.Station,

                    lastPassHeight1 = lastPassHeight1,
                    lastPassHeight2 = lastPassHeight2,
                    designHeight    = designHeight,
                    cutFill         = cutFill
                });

                prevCell = currCell;
            }

            //Add a last point at the intercept length of the last cell so profiles are drawn correctly
            if (prevCell != null && prevCell.InterceptLength > ProfilesHelper.ONE_MM)
            {
                var lastCell = new CompactionSummaryVolumesProfileCell(profile.results[profile.results.Count - 1])
                {
                    station = prevCell.Station + prevCell.InterceptLength
                };

                profile.results.Add(lastCell);
            }

            if (profile.results.Count > 0)
            {
                profile.results[profile.results.Count - 1].cellType = ProfileCellType.MidPoint;
            }

            profile.gridDistanceBetweenProfilePoints = gridDistanceBetweenProfilePoints;

            var sb = new StringBuilder();

            sb.Append($"After summary volumes profile conversion: {profile.results.Count}");
            foreach (var cell in profile.results)
            {
                sb.Append($",{cell.cellType}");
            }

            log.LogDebug(sb.ToString());
            return(profile);
        }
Exemplo n.º 16
0
        private CompactionProfileResult <CompactionSummaryVolumesProfileCell> ProcessSummaryVolumesWithRaptor(CompactionProfileProductionDataRequest request)
        {
            var alignmentDescriptor = RaptorConverters.DesignDescriptor(request.AlignmentDesign);
            var liftBuildSettings   =
                RaptorConverters.ConvertLift(request.LiftBuildSettings, TFilterLayerMethod.flmNone);
            var baseFilter             = RaptorConverters.ConvertFilter(request.BaseFilter, request.ProjectId, raptorClient);
            var topFilter              = RaptorConverters.ConvertFilter(request.TopFilter, request.ProjectId, raptorClient);
            var volumeDesignDescriptor = RaptorConverters.DesignDescriptor(request.VolumeDesignDescriptor);

            ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out var startPt, out var endPt,
                                                      out var positionsAreGrid);

            if (request.VolumeCalcType.HasValue && request.VolumeCalcType.Value != VolumeCalcType.None)
            {
                var volCalcType = (TComputeICVolumesType)request.VolumeCalcType.Value;
                if (volCalcType == TComputeICVolumesType.ic_cvtBetween2Filters && !request.ExplicitFilters)
                {
                    RaptorConverters.AdjustFilterToFilter(ref baseFilter, topFilter);
                }

                MemoryStream memoryStream;
                if (request.IsAlignmentDesign)
                {
                    var args
                        = ASNode.RequestSummaryVolumesAlignmentProfile.RPC.__Global
                          .Construct_RequestSummaryVolumesAlignmentProfile_Args
                              (request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                              ProfilesHelper.PROFILE_TYPE_NOT_REQUIRED,
                              volCalcType,
                              request.StartStation ?? ValidationConstants3D.MIN_STATION,
                              request.EndStation ?? ValidationConstants3D.MIN_STATION,
                              alignmentDescriptor,
                              baseFilter,
                              topFilter,
                              liftBuildSettings,
                              volumeDesignDescriptor);

                    memoryStream = raptorClient.GetSummaryVolumesAlignmentProfile(args);
                }
                else
                {
                    var args
                        = ASNode.RequestSummaryVolumesProfile.RPC.__Global.Construct_RequestSummaryVolumesProfile_Args(
                              request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                              ProfilesHelper.PROFILE_TYPE_HEIGHT,
                              volCalcType,
                              startPt,
                              endPt,
                              positionsAreGrid,
                              baseFilter,
                              topFilter,
                              liftBuildSettings,
                              volumeDesignDescriptor);
                    memoryStream = raptorClient.GetSummaryVolumesProfile(args);
                }

                return(memoryStream != null?ConvertSummaryVolumesProfileResult(memoryStream, request.VolumeCalcType.Value) : null);
            }

            return(null);
        }
Exemplo n.º 17
0
        private CompactionProfileResult <CompactionProfileCell> ProcessProductionDataProfileCells(List <ProfileCellData> profileCells, double gridDistanceBetweenProfilePoints, LiftBuildSettings liftBuildSettings)
        {
            var profile = new CompactionProfileResult <CompactionProfileCell>();

            profile.results = new List <CompactionProfileCell>();
            ProfileCellData prevCell = null;

            foreach (var currCell in profileCells)
            {
                var gapExists = ProfilesHelper.CellGapExists(prevCell, currCell, out double prevStationIntercept);

                if (gapExists)
                {
                    var gapCell = new CompactionProfileCell(GapCell);
                    gapCell.station = prevStationIntercept;
                    profile.results.Add(gapCell);
                }

                var lastPassHeight = currCell.LastPassHeight == VelociraptorConstants.NULL_SINGLE
          ? float.NaN
          : currCell.LastPassHeight;
                var lastCompositeHeight = currCell.CompositeLastPassHeight == VelociraptorConstants.NULL_SINGLE
        ? float.NaN
          : currCell.CompositeLastPassHeight;

                var designHeight = currCell.DesignHeight == VelociraptorConstants.NULL_SINGLE
        ? float.NaN
          : currCell.DesignHeight;
                bool noCCVValue = currCell.TargetCCV == 0 || currCell.TargetCCV == VelociraptorConstants.NO_CCV ||
                                  currCell.CCV == VelociraptorConstants.NO_CCV;
                bool noCCVElevation = currCell.CCVElev == VelociraptorConstants.NULL_SINGLE || noCCVValue;
                bool noMDPValue     = currCell.TargetMDP == 0 || currCell.TargetMDP == VelociraptorConstants.NO_MDP ||
                                      currCell.MDP == VelociraptorConstants.NO_MDP;
                bool noMDPElevation         = currCell.MDPElev == VelociraptorConstants.NULL_SINGLE || noMDPValue;
                bool noTemperatureValue     = currCell.MaterialTemperature == VelociraptorConstants.NO_TEMPERATURE;
                bool noTemperatureElevation = currCell.MaterialTemperatureElev == VelociraptorConstants.NULL_SINGLE ||
                                              noTemperatureValue;
                bool noPassCountValue = currCell.TopLayerPassCount == VelociraptorConstants.NO_PASSCOUNT;

                //Either have none or both speed values
                var noSpeedValue = currCell.CellMaxSpeed == VelociraptorConstants.NO_SPEED;
                var speedMin     = noSpeedValue ? float.NaN : (float)(currCell.CellMinSpeed / ConversionConstants.KM_HR_TO_CM_SEC);
                var speedMax     = noSpeedValue ? float.NaN : (float)(currCell.CellMaxSpeed / ConversionConstants.KM_HR_TO_CM_SEC);

                var cmvPercent = noCCVValue
          ? float.NaN
          : (float)currCell.CCV / (float)currCell.TargetCCV * 100.0F;

                var mdpPercent = noMDPValue
          ? float.NaN
          : (float)currCell.MDP / (float)currCell.TargetMDP * 100.0F;

                var firstPassHeight = currCell.FirstPassHeight == VelociraptorConstants.NULL_SINGLE
        ? float.NaN
          : currCell.FirstPassHeight;

                var highestPassHeight = currCell.HighestPassHeight == VelociraptorConstants.NULL_SINGLE
        ? float.NaN
          : currCell.HighestPassHeight;

                var lowestPassHeight = currCell.LowestPassHeight == VelociraptorConstants.NULL_SINGLE
        ? float.NaN
          : currCell.LowestPassHeight;

                var cutFill = float.IsNaN(lastCompositeHeight) || float.IsNaN(designHeight)
          ? float.NaN
          : lastCompositeHeight - designHeight;

                var cmv         = noCCVValue ? float.NaN : currCell.CCV / 10.0F;
                var cmvHeight   = noCCVElevation ? float.NaN : currCell.CCVElev;
                var mdpHeight   = noMDPElevation ? float.NaN : currCell.MDPElev;
                var temperature =
                    noTemperatureValue
            ? float.NaN
            : currCell.MaterialTemperature / 10.0F; // As temperature is reported in 10th...
                var temperatureHeight = noTemperatureElevation ? float.NaN : currCell.MaterialTemperatureElev;
                var topLayerPassCount = noPassCountValue ? -1 : currCell.TopLayerPassCount;
                var cmvPercentChange  = currCell.CCV == VelociraptorConstants.NO_CCV
          ? float.NaN
          : (currCell.PrevCCV == VelociraptorConstants.NO_CCV
            ? 100.0f
            : (float)(currCell.CCV - currCell.PrevCCV) / (float)currCell.PrevCCV * 100.0f);

                var passCountIndex = noPassCountValue || float.IsNaN(lastPassHeight)
          ? ValueTargetType.NoData
          : (currCell.TopLayerPassCount < currCell.TopLayerPassCountTargetRangeMin
            ? ValueTargetType.BelowTarget
            : (currCell.TopLayerPassCount > currCell.TopLayerPassCountTargetRangeMax
              ? ValueTargetType.AboveTarget
              : ValueTargetType.OnTarget));

                var temperatureIndex = noTemperatureValue || noTemperatureElevation
          ? ValueTargetType.NoData
          : (currCell.MaterialTemperature < currCell.MaterialTemperatureWarnMin
            ? ValueTargetType.BelowTarget
            : (currCell.MaterialTemperature > currCell.MaterialTemperatureWarnMax
              ? ValueTargetType.AboveTarget
              : ValueTargetType.OnTarget));

                var cmvIndex = noCCVValue || noCCVElevation
          ? ValueTargetType.NoData
          : (cmvPercent < liftBuildSettings.CCVRange.Min
            ? ValueTargetType.BelowTarget
            : (cmvPercent > liftBuildSettings.CCVRange.Max ? ValueTargetType.AboveTarget : ValueTargetType.OnTarget));

                var mdpIndex = noMDPValue || noMDPElevation
          ? ValueTargetType.NoData
          : (mdpPercent < liftBuildSettings.MDPRange.Min
            ? ValueTargetType.BelowTarget
            : (mdpPercent > liftBuildSettings.MDPRange.Max ? ValueTargetType.AboveTarget : ValueTargetType.OnTarget));

                var speedIndex = noSpeedValue || float.IsNaN(lastPassHeight)
          ? ValueTargetType.NoData
          : (currCell.CellMaxSpeed > liftBuildSettings.MachineSpeedTarget.MaxTargetMachineSpeed
            ? ValueTargetType.AboveTarget
            : (currCell.CellMinSpeed < liftBuildSettings.MachineSpeedTarget.MinTargetMachineSpeed &&
               currCell.CellMaxSpeed < liftBuildSettings.MachineSpeedTarget.MinTargetMachineSpeed
              ? ValueTargetType.BelowTarget
              : ValueTargetType.OnTarget));

                profile.results.Add(new CompactionProfileCell
                {
                    cellType = prevCell == null ? ProfileCellType.MidPoint : ProfileCellType.Edge,

                    station = currCell.Station,

                    firstPassHeight   = firstPassHeight,
                    highestPassHeight = highestPassHeight,
                    lastPassHeight    = lastPassHeight,
                    lowestPassHeight  = lowestPassHeight,

                    lastCompositeHeight = lastCompositeHeight,
                    designHeight        = designHeight,

                    cutFill = cutFill,

                    cmv        = cmv,
                    cmvPercent = cmvPercent,
                    cmvHeight  = cmvHeight,

                    mdpPercent = mdpPercent,
                    mdpHeight  = mdpHeight,

                    temperature       = temperature,
                    temperatureHeight = temperatureHeight,

                    topLayerPassCount = topLayerPassCount,

                    cmvPercentChange = cmvPercentChange,

                    minSpeed = speedMin,
                    maxSpeed = speedMax,

                    passCountIndex   = passCountIndex,
                    temperatureIndex = temperatureIndex,
                    cmvIndex         = cmvIndex,
                    mdpIndex         = mdpIndex,
                    speedIndex       = speedIndex
                });

                prevCell = currCell;
            }

            //Add a last point at the intercept length of the last cell so profiles are drawn correctly
            if (prevCell != null && prevCell.InterceptLength > ProfilesHelper.ONE_MM)
            {
                var lastCell = new CompactionProfileCell(profile.results[profile.results.Count - 1])
                {
                    station = prevCell.Station + prevCell.InterceptLength
                };

                profile.results.Add(lastCell);
            }

            if (profile.results.Count > 0)
            {
                profile.results[profile.results.Count - 1].cellType = ProfileCellType.MidPoint;
            }

            profile.gridDistanceBetweenProfilePoints = gridDistanceBetweenProfilePoints;

            var sb = new StringBuilder();

            sb.Append($"After profile conversion: {profile.results.Count}");
            foreach (var cell in profile.results)
            {
                sb.Append($",{cell.cellType}");
            }

            log.LogDebug(sb.ToString());
            return(profile);
        }
Exemplo n.º 18
0
        private static ProfileResult ProcessProfileCells(List <ProfileCellData> profileCells, double gridDistanceBetweenProfilePoints, Guid callerId)
        {
            var profile = new ProfileResult()
            {
                callId = callerId,
                cells  = null
            };

            profile.cells = new List <ProfileCell>();
            ProfileCellData prevCell = null;

            foreach (var currCell in profileCells)
            {
                var gapExists = ProfilesHelper.CellGapExists(prevCell, currCell, out double prevStationIntercept);

                if (gapExists)
                {
                    profile.cells.Add(new ProfileCell()
                    {
                        station                      = prevStationIntercept,
                        firstPassHeight              = float.NaN,
                        highestPassHeight            = float.NaN,
                        lastPassHeight               = float.NaN,
                        lowestPassHeight             = float.NaN,
                        firstCompositeHeight         = float.NaN,
                        highestCompositeHeight       = float.NaN,
                        lastCompositeHeight          = float.NaN,
                        lowestCompositeHeight        = float.NaN,
                        designHeight                 = float.NaN,
                        cmvPercent                   = float.NaN,
                        cmvHeight                    = float.NaN,
                        previousCmvPercent           = float.NaN,
                        mdpPercent                   = float.NaN,
                        mdpHeight                    = float.NaN,
                        temperature                  = float.NaN,
                        temperatureHeight            = float.NaN,
                        temperatureLevel             = -1,
                        topLayerPassCount            = -1,
                        topLayerPassCountTargetRange = new TargetPassCountRange(VelociraptorConstants.NO_PASSCOUNT, VelociraptorConstants.NO_PASSCOUNT),
                        passCountIndex               = -1,
                        topLayerThickness            = float.NaN
                    });
                }

                bool noCCVValue             = currCell.TargetCCV == 0 || currCell.TargetCCV == VelociraptorConstants.NO_CCV || currCell.CCV == VelociraptorConstants.NO_CCV;
                bool noCCElevation          = currCell.CCVElev == VelociraptorConstants.NULL_SINGLE || noCCVValue;
                bool noMDPValue             = currCell.TargetMDP == 0 || currCell.TargetMDP == VelociraptorConstants.NO_MDP || currCell.MDP == VelociraptorConstants.NO_MDP;
                bool noMDPElevation         = currCell.MDPElev == VelociraptorConstants.NULL_SINGLE || noMDPValue;
                bool noTemperatureValue     = currCell.MaterialTemperature == VelociraptorConstants.NO_TEMPERATURE;
                bool noTemperatureElevation = currCell.MaterialTemperatureElev == VelociraptorConstants.NULL_SINGLE || noTemperatureValue;
                bool noPassCountValue       = currCell.TopLayerPassCount == VelociraptorConstants.NO_PASSCOUNT;

                profile.cells.Add(new ProfileCell
                {
                    station = currCell.Station,

                    firstPassHeight   = currCell.FirstPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.FirstPassHeight,
                    highestPassHeight = currCell.HighestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.HighestPassHeight,
                    lastPassHeight    = currCell.LastPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LastPassHeight,
                    lowestPassHeight  = currCell.LowestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.LowestPassHeight,

                    firstCompositeHeight   = currCell.CompositeFirstPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeFirstPassHeight,
                    highestCompositeHeight = currCell.CompositeHighestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeHighestPassHeight,
                    lastCompositeHeight    = currCell.CompositeLastPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeLastPassHeight,
                    lowestCompositeHeight  = currCell.CompositeLowestPassHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.CompositeLowestPassHeight,
                    designHeight           = currCell.DesignHeight == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.DesignHeight,

                    cmvPercent = noCCVValue
            ? float.NaN : (float)currCell.CCV / (float)currCell.TargetCCV * 100.0F,
                    cmvHeight          = noCCElevation ? float.NaN : currCell.CCVElev,
                    previousCmvPercent = noCCVValue
            ? float.NaN : (float)currCell.PrevCCV / (float)currCell.PrevTargetCCV * 100.0F,

                    mdpPercent = noMDPValue
            ? float.NaN : (float)currCell.MDP / (float)currCell.TargetMDP * 100.0F,
                    mdpHeight = noMDPElevation ? float.NaN : currCell.MDPElev,

                    temperature       = noTemperatureValue ? float.NaN : currCell.MaterialTemperature / 10.0F,// As temperature is reported in 10th...
                    temperatureHeight = noTemperatureElevation ? float.NaN : currCell.MaterialTemperatureElev,
                    temperatureLevel  = noTemperatureValue ? -1 :
                                        (currCell.MaterialTemperature < currCell.MaterialTemperatureWarnMin ? 2 :
                                         (currCell.MaterialTemperature > currCell.MaterialTemperatureWarnMax ? 0 : 1)),

                    topLayerPassCount            = noPassCountValue ? -1 : currCell.TopLayerPassCount,
                    topLayerPassCountTargetRange = new TargetPassCountRange(currCell.TopLayerPassCountTargetRangeMin, currCell.TopLayerPassCountTargetRangeMax),

                    passCountIndex = noPassCountValue ? -1 :
                                     (currCell.TopLayerPassCount < currCell.TopLayerPassCountTargetRangeMin ? 2 :
                                      (currCell.TopLayerPassCount > currCell.TopLayerPassCountTargetRangeMax ? 0 : 1)),

                    topLayerThickness = currCell.TopLayerThickness == VelociraptorConstants.NULL_SINGLE ? float.NaN : currCell.TopLayerThickness
                });

                prevCell = currCell;
            }
            //Add a last point at the intercept length of the last cell so profiles are drawn correctly
            if (prevCell != null)
            {
                ProfileCell lastCell = profile.cells[profile.cells.Count - 1];
                profile.cells.Add(new ProfileCell()
                {
                    station                      = prevCell.Station + prevCell.InterceptLength,
                    firstPassHeight              = lastCell.firstPassHeight,
                    highestPassHeight            = lastCell.highestPassHeight,
                    lastPassHeight               = lastCell.lastPassHeight,
                    lowestPassHeight             = lastCell.lowestPassHeight,
                    firstCompositeHeight         = lastCell.firstCompositeHeight,
                    highestCompositeHeight       = lastCell.highestCompositeHeight,
                    lastCompositeHeight          = lastCell.lastCompositeHeight,
                    lowestCompositeHeight        = lastCell.lowestCompositeHeight,
                    designHeight                 = lastCell.designHeight,
                    cmvPercent                   = lastCell.cmvPercent,
                    cmvHeight                    = lastCell.cmvHeight,
                    mdpPercent                   = lastCell.mdpPercent,
                    mdpHeight                    = lastCell.mdpHeight,
                    temperature                  = lastCell.temperature,
                    temperatureHeight            = lastCell.temperatureHeight,
                    temperatureLevel             = lastCell.temperatureLevel,
                    topLayerPassCount            = lastCell.topLayerPassCount,
                    topLayerPassCountTargetRange = lastCell.topLayerPassCountTargetRange,
                    passCountIndex               = lastCell.passCountIndex,
                    topLayerThickness            = lastCell.topLayerThickness,
                    previousCmvPercent           = lastCell.previousCmvPercent
                });
            }

            profile.gridDistanceBetweenProfilePoints = gridDistanceBetweenProfilePoints;

            return(profile);
        }
        public async Task <IActionResult> Index()
        {
            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            if (user == null)
            {
                return(RedirectToAction("Index", "Index"));
            }

            try
            {
                if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Free)
                {
                    ViewBag.AccountType = "Free";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                {
                    ViewBag.AccountType = "Deluxe";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Premium)
                {
                    ViewBag.AccountType = "Premium";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                {
                    ViewBag.AccountType = "Topaz";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                {
                    ViewBag.AccountType = "Platinum";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Gold)
                {
                    ViewBag.AccountType = "Gold";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                {
                    ViewBag.AccountType = "Ruby";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Standard)
                {
                    ViewBag.AccountType = "Standard";
                }
                if (user.ExpiryDate < DateTime.UtcNow)
                {
                    //return RedirectToAction("UpgradePlans", "Index");
                    if (user.TrailStatus != Domain.Socioboard.Enum.UserTrailStatus.inactive)
                    {
                        List <KeyValuePair <string, string> > Param = new List <KeyValuePair <string, string> >();
                        Param.Add(new KeyValuePair <string, string>("Id", user.Id.ToString()));
                        HttpResponseMessage respon = await WebApiReq.PostReq("/api/User/UpdateTrialStatus", Param, "", "", _appSettings.ApiDomain);

                        if (respon.IsSuccessStatusCode)
                        {
                            Domain.Socioboard.Models.User _user = await respon.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                            HttpContext.Session.SetObjectAsJson("User", _user);
                            user = _user;
                        }
                    }
                }
                else if ((user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.notadded || user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.inprogress) && (user.AccountType != Domain.Socioboard.Enum.SBAccountType.Free))
                {
                    return(RedirectToAction("PayPalAccount", "Home", new { emailId = user.EmailId, IsLogin = true }));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Index", "Index"));
            }
            HttpResponseMessage response = await WebApiReq.GetReq("/api/Groups/GetUserGroups?userId=" + user.Id, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                try
                {
                    List <Domain.Socioboard.Models.Groups> groups = await response.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groups> >();

                    ViewBag.groups = Newtonsoft.Json.JsonConvert.SerializeObject(groups);
                    string sessionSelectedGroupId = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");
                    if (!string.IsNullOrEmpty(sessionSelectedGroupId))
                    {
                        ViewBag.selectedGroupId = sessionSelectedGroupId;
                        HttpResponseMessage groupProfilesResponse = await WebApiReq.GetReq("/api/GroupProfiles/GetGroupProfiles?groupId=" + sessionSelectedGroupId, "", "", _appSettings.ApiDomain);

                        if (groupProfilesResponse.IsSuccessStatusCode)
                        {
                            List <Domain.Socioboard.Models.Groupprofiles> groupProfiles = await groupProfilesResponse.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groupprofiles> >();

                            ViewBag.groupProfiles = Newtonsoft.Json.JsonConvert.SerializeObject(groupProfiles);
                            string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);

                            int count    = Convert.ToInt32(profileCount);
                            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);
                            ViewBag.profileCount = count;
                            ViewBag.MaxCount     = MaxCount;
                            ViewBag.AccountType  = user.AccountType;
                            if (count > MaxCount)
                            {
                                ViewBag.downgrade = "true";
                            }
                            else
                            {
                                ViewBag.downgrade = "false";
                            }
                        }
                    }
                    else
                    {
                        long selectedGroupId = groups.FirstOrDefault(t => t.groupName == Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName).id;
                        HttpContext.Session.SetObjectAsJson("selectedGroupId", selectedGroupId);
                        ViewBag.selectedGroupId = selectedGroupId;
                        HttpResponseMessage groupProfilesResponse = await WebApiReq.GetReq("/api/GroupProfiles/GetGroupProfiles?groupId=" + selectedGroupId, "", "", _appSettings.ApiDomain);

                        if (groupProfilesResponse.IsSuccessStatusCode)
                        {
                            List <Domain.Socioboard.Models.Groupprofiles> groupProfiles = await groupProfilesResponse.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groupprofiles> >();

                            ViewBag.groupProfiles = Newtonsoft.Json.JsonConvert.SerializeObject(groupProfiles);
                            string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);

                            int count    = Convert.ToInt32(profileCount);
                            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);
                            ViewBag.profileCount = count;
                            ViewBag.MaxCount     = MaxCount;
                            if (count > MaxCount)
                            {
                                ViewBag.downgrade = "true";
                            }
                            else
                            {
                                ViewBag.downgrade = "false";
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    HttpContext.Session.Remove("User");
                    HttpContext.Session.Remove("selectedGroupId");
                    HttpContext.Session.Clear();
                    ViewBag.user            = null;
                    ViewBag.selectedGroupId = null;
                    ViewBag.groupProfiles   = null;
                    TempData["Error"]       = "Some thing went wrong.";
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Index"));
            }
            ViewBag.user = Newtonsoft.Json.JsonConvert.SerializeObject(user);
            return(View());
        }
Exemplo n.º 20
0
        public ActionResult Edit(ProfilesEditViewModels model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var profiles = new ProfilesHelper();

                    var profile = new Profile()
                    {
                        UserId = User.Identity.GetUserId(),
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        Address = model.Address,
                        DOB = model.DoB,
                        GenderId = (int)model.Gender,
                        Telephone = model.Telephone
                    };
                    profiles.Update(profile);

                    return RedirectToAction("Details");
                }
                return View(model);
            }
            catch
            {
                return View();
            }
        }