public async Task <IActionResult> UpdateClientProfile(Guid id, [FromBody] ClientProfileViewModel formdata)
        {
            try
            {
                if (formdata == null)
                {
                    return(BadRequest(new JsonResult(new { message = "object sent from client is null." })));
                }
                if (id == null || id == Guid.Empty)
                {
                    return(BadRequest(new JsonResult(new { message = "object sent from client is null." })));
                }
                if (id != formdata.Id)
                {
                    return(BadRequest(new JsonResult(new { message = "please ensure you are updating right object" })));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model object sent from client."));
                }
                var clientProfile   = _mapper.Map <ClientProfileDto>(formdata);
                var clientProfileId = await _clientProfileService.UpdateClientProfile(clientProfile);

                if (clientProfileId == Guid.Empty)
                {
                    return(NotFound());
                }
                clientProfile.Id = clientProfileId;
                return(CreatedAtAction(nameof(GetClientProfile), new { id = clientProfileId }, _mapper.Map <ClientProfileViewModel>(clientProfile)));
            }
            catch (Exception e)
            {
                return(StatusCode(500, new JsonResult(new { message = $"Something went wrong inside update clientProfile action: {e.Message}" })));
            }
        }
        public async Task <IActionResult> AddClientProfile([FromBody] ClientProfileViewModel formdata)
        {
            try
            {
                if (formdata == null)
                {
                    return(BadRequest(new JsonResult(new { message = "object sent from client is null." })));
                }
                else if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model object sent from client."));
                }
                var clientProfile     = _mapper.Map <ClientProfileDto>(formdata);
                var clientProfileData = await _clientProfileService.AddClientProfile(clientProfile);

                if (clientProfileData == Guid.Empty)
                {
                    return(NotFound());
                }
                clientProfile.Id = clientProfileData;
                var addedClientProfile = _mapper.Map <ClientProfileViewModel>(clientProfile);
                return(CreatedAtAction(nameof(GetClientProfile), new { id = clientProfileData }, addedClientProfile));
            }
            catch (Exception e)
            {
                return(StatusCode(500, $"Something went wrong inside add clientProfile action: {e.Message}"));
            }
        }
Exemple #3
0
        public ActionResult ClientProfile(ClientProfileViewModel clientProfile)
        {
            if (ModelState.IsValid)
            {
                Client client = new Client
                {
                    FullName = clientProfile.FullName,
                    Address1 = clientProfile.Address1,
                    Address2 = clientProfile.Address2,
                    City     = clientProfile.City,
                    State    = clientProfile.State.ToString(),
                    ZipCode  = clientProfile.ZipCode,
                    Email    = User.Identity.Name
                };

                User usrDetails = new User();
                client.User_ID    = usrDetails;
                client.User_ID.Id = _FuelQuoteRepo.GetUserID(User.Identity.Name);
                Client AddedClient = _FuelQuoteRepo.AddClient(client);

                return(RedirectToAction("ClientDashBoard", "Client"));
            }
            else
            {
                return(View());
            }
        }
Exemple #4
0
        public ActionResult Create()
        {
            int userId    = this.MembershipService.UserId();
            int companyId = this.UserModelService.GetUser(userId).CompanyId;

            ClientProfileViewModel clientModel = ClientProfileVMService.NewClient(companyId);

            return(View(clientModel));
        }
Exemple #5
0
        public ActionResult DisplayClientProfile(string userName)
        {
            var model = new ClientProfileViewModel {
                QuestionsAsked   = _questionRepository.Questions.WithCreatedBy(userName).Count(),
                QuestionsInQueue = _questionRepository.Questions.WithCreatedBy(userName).Active().NotTaken().Count(),
                QuestionsTaken   = _questionRepository.Questions.WithCreatedBy(userName).Active().Taken().Count()
            };

            return(View(model));
        }
Exemple #6
0
        public ActionResult Edit(int id)
        {
            ClientProfileViewModel clientProfileVM = this.ClientProfileVMService.GetClient(id);

            if (clientProfileVM == null)
            {
                return(new HttpNotFoundResult());
            }
            return(View(clientProfileVM));
        }
Exemple #7
0
        public ClientProfileViewModel NewClient(int companyLocationId)
        {
            //build
            ClientProfileViewModel clientProfileVM = new ClientProfileViewModel();

            clientProfileVM.StatesSL       = new SelectList(this.GetStateSLI(), "Value", "Text");
            clientProfileVM.ClientProfileM = new ClientProfileModel();
            clientProfileVM.ClientProfileM.CompanyLocationId = companyLocationId;

            return(clientProfileVM);
        }
Exemple #8
0
 public ActionResult ClientProfile(ClientProfileViewModel clientProfile)
 {
     if (ModelState.IsValid)
     {
         return(RedirectToAction("GetQuote", "Quote"));
     }
     else
     {
         return(View());
     }
 }
Exemple #9
0
        public static ClientProfileDTO CreateFromView(ClientProfileViewModel clientProfileViewModel)
        {
            var relTypeId = null != clientProfileViewModel.SelectedRelationshipType
                ? clientProfileViewModel.SelectedRelationshipType.Id
                : "";

            var profileDTO = new ClientProfileDTO(clientProfileViewModel.SelectedMaritalStatus.Id, clientProfileViewModel.SelectedKeyPop.Id, clientProfileViewModel.OtherKeyPop, relTypeId,
                                                  clientProfileViewModel.SelectedEducation?.ItemId, clientProfileViewModel.SelectedCompletion?.ItemId, clientProfileViewModel.SelectedOccupation?.ItemId);

            profileDTO.ClientId = clientProfileViewModel.ClientId;
            return(profileDTO);
        }
        public void ClientProfileTest()
        {
            ClientProfileViewModel clientProfile = new ClientProfileViewModel()
            {
                Address1 = "Linkwood Drive",
                Address2 = "Apt 641",
                City     = "Houston",
                FullName = "Adarsh",
                State    = States.AK,
                ZipCode  = "15212"
            };

            var result = _controllerClient.ClientProfile(clientProfile);

            Assert.IsType <ViewResult>(result);
        }
        public void ClientZipCodeValidation()
        {
            //Hardcoding dummy user Info data
            ClientProfileViewModel clientProfile = new ClientProfileViewModel()
            {
                Address1 = "Linkwood Drive",
                Address2 = "Apt 641",
                City     = "Houston",
                FullName = "Adarsh",
                State    = States.AK,
                ZipCode  = "152dsfsdf12" //passing invalid zipcode
            };

            var result = _controllerClient.ClientProfileDataValidation(clientProfile);

            //Check if all the validation passed
            Assert.True(result);
        }
        public void ClientAddressValidation()
        {
            //Hardcoding dummy user Info data
            ClientProfileViewModel clientProfile = new ClientProfileViewModel()
            {
                Address1 = "",
                Address2 = "Apt 641",
                City     = "Houston",
                FullName = "", //passing empty invalid name for testing
                State    = States.AK,
                ZipCode  = "15212"
            };

            var result = _controllerClient.ClientProfileDataValidation(clientProfile);

            //Check if all the validation passed
            Assert.True(result);
        }
Exemple #13
0
        public async Task <ClientProfileViewModel> GetClientProfile(int id)
        {
            try
            {
                // Instantiate a new ClientProfileViewModel
                ClientProfileViewModel cp = new ClientProfileViewModel();

                // Load ClientProfile for ClientProfileId
                var clientProfile = await _clientProfileRepository.GetClientProfile(id);

                cp.ClientProfile = (ClientProfile)clientProfile;

                // Load Person for ClientProfileId
                var personVM = _personRepository.GetPersonForClientProfile(id);
                cp.Person = personVM;

                // Load Assessment(s) for ClientProfileId
                var assessment = _assessmentRepository.GetAssessmentsForClientProfile(id);
                cp.Assessment = assessment;

                // Load Placement(s) for ClientProfileId
                cp.Placement = GetPlacementsForClientProfile(id);

                cp.EducationLevels = context.EducationLevel.ToList();

                cp.FundingSources = context.FundingSource.ToList();

                cp.JobStatuses = context.JobStatus.ToList();

                cp.MaritalStatuses = context.MaritalStatus.ToList();

                cp.Races = context.Race.ToList();

                cp.Genders = context.Gender.ToList();

                cp.Suffixes = context.Suffix.ToList();

                return(cp);
            }
            catch (Exception E)
            {
                throw E;
            }
        }
Exemple #14
0
        public IActionResult DisplayProfile()
        {
            Client client = new Client();

            client = JsonConvert.DeserializeObject <Client>(HttpContext.Session.GetString("ClientDetails"));


            ClientProfileViewModel cl = new ClientProfileViewModel()
            {
                FullName = client.FullName,
                Address1 = client.Address1,
                Address2 = client.Address2,
                City     = client.City,
                State    = States.AK,
                ZipCode  = client.ZipCode
            };

            return(View(cl));
        }
Exemple #15
0
        public async Task <IActionResult> Profile(ClientProfileViewModel model)
        {
            User profile = await profileService.FindByIdAsync(model.Id)
                           ?? await profileService.FindByNameAsync(model.Id);

            if (profile.UserName != model.Alias && await profileService.FindByNameAsync(model.Alias) != null)
            {
                ViewData[ErrorKey] = $"Alias '{model.Alias}' is already taken.";
                return(View(model));
            }
            if (!string.IsNullOrWhiteSpace(model.Alias))
            {
                profile.UserName = model.Alias;
            }
            if (!string.IsNullOrWhiteSpace(model.EmailAddress) && profile.Email != model.EmailAddress)
            {
                profile.Email          = model.EmailAddress;
                profile.EmailConfirmed = false;
            }
            profile.PhoneNumber = model.PhoneNumber;
            if (profile.Client != null)
            {
                profile.Client.CompanyName     = model.CompanyName;
                profile.Client.FirstName       = model.FirstName;
                profile.Client.LastName        = model.LastName;
                profile.Client.ShippingAddress = model.ShippingAddress;
            }
            var profileUpdateResult = await profileService.UpdateAsync(profile);

            if (!profileUpdateResult.Succeeded)
            {
                ViewData[ErrorKey] = profileUpdateResult.Errors.Select(e => e.Description);
                return(View(model));
            }
            if (profile.EmailConfirmed == false)
            {
                await RequestEmailVerificationAsync(profile);
            }
            logger.LogInformation($"'{profile.UserName}' updated their profile.");
            ViewData[InfoKey] = "Profile updated.";
            return(View(model));
        }
Exemple #16
0
        public ClientProfileViewModel GetClient(int clientId)
        {
            ClientProfile clientProfile = this.Repository.Single <ClientProfile>(x => x.id_client == clientId);

            if (clientProfile == null)
            {
                return(null);
            }
            ClientProfileModel clientProfileModel = Mapper.Map <ClientProfileModel>(clientProfile);

            clientProfileModel.ClientName        = clientProfile.client_name;
            clientProfileModel.ClientId          = clientProfile.id_client;
            clientProfileModel.CompanyLocationId = clientProfile.fk_company_location;
            clientProfileModel.StateId           = clientProfile.fk_state;
            clientProfileModel.Zip4    = clientProfile.zip_4;
            clientProfileModel.Deleted = clientProfile.deleted_on != null;

            ClientProfileViewModel clientProfileVM = new ClientProfileViewModel();

            clientProfileVM.ClientProfileM = clientProfileModel;
            clientProfileVM.StatesSL       = new SelectList(this.GetStateSLI(), "Value", "Text");

            return(clientProfileVM);
        }
Exemple #17
0
        public bool ClientProfileDataValidation(ClientProfileViewModel data)
        {
            bool flag = false;

            if ((data.FullName.Length <= 50) && (data.FullName != String.Empty))
            {
                if (((data.Address1.Length <= 100) && (data.Address1 != String.Empty)) && (data.Address2.Length <= 100))
                {
                    if ((data.City.Length <= 100) && (data.City != String.Empty))
                    {
                        if (data.ZipCode.Length <= 9 && data.ZipCode.Length >= 5)
                        {
                            flag = true;
                        }
                    }
                }
            }
            else
            {
                flag = false;
            }

            return(flag);
        }
Exemple #18
0
        /// <summary>
        /// Reads the incoming socket bytes
        /// </summary>
        /// <param name="client"></param>
        void HandleConnection(Socket client)
        {
            Console.WriteLine("Connection with server () established!");

            ClientProfile configInitClient = new ClientProfile
            {
                CoffeePoints    = Properties.Settings.Default.user_coffeePoints,
                DrinkPreference = new DrinkPreference()
                {
                    DrinkType = ClientProfileViewModel.ParseEnum <DrinkType>(Properties.Settings.Default.user_drinktype),
                    WithMilk  = Properties.Settings.Default.user_withmilk,
                    WithSugar = Properties.Settings.Default.user_withsugar
                },
                Name = Properties.Settings.Default.user_name
            };

            MainWindow.ClientSocket.SendCommand("update", configInitClient);

            const int maxMessageSize = 1024;

            while (true)
            {
                var response = new byte[maxMessageSize];
                var received = client.Receive(response);

                if (received == 0)
                {
                    return;
                }

                var respBytesList = new List <byte>(response);
                respBytesList.RemoveRange(received, maxMessageSize - received);

                string message = Encoding.ASCII.GetString(respBytesList.ToArray());

                string serverCommand = JsonConvert.DeserializeObject <ServerCommand>(message).Command;

                Debug.WriteLine("Command " + serverCommand + "received");
                switch (serverCommand)
                {
                case "start_vote":
                    ClientVotedCommand votedClient1 = JsonConvert.DeserializeObject <ClientVotedCommand>(message);

                    VoteStartedEvent(new VoteStartedEventArgs(votedClient1.Client));
                    break;

                case "client_voted":
                    ClientVotedCommand votedClient2 = JsonConvert.DeserializeObject <ClientVotedCommand>(message);
                    VoteReceivedEvent(new ClientVoteReceivedEventArgs(votedClient2.Client));
                    break;

                case "end_vote":
                    VoteEndedCommand winnerClient = JsonConvert.DeserializeObject <VoteEndedCommand>(message);
                    VoteEndedEvent(new VoteEndedEventArgs(winnerClient.Winner)
                    {
                        Clients = winnerClient.Clients
                    });
                    break;
                }
            }
        }
Exemple #19
0
        private async Task InitializeAsync()
        {
            userProfile = await IdentityService.GetUserProfileAsync();

            if (!string.IsNullOrEmpty(Id))
            {
                if (Guid.TryParse(Id, out var id))
                {
                    try
                    {
                        client = Mapper.Map <UpdateClientProfile>(
                            await ClientProfilesClient.GetClientProfileAsync(Guid.Parse(Id)));
                        if (client.Address == null)
                        {
                            client.Address = new Address();
                        }
                    }

                    /* catch (ApiException exc)
                     * {
                     * }
                     * catch (HttpRequestException exc)
                     * {
                     * } */
                    catch (Exception exc)
                    {
                        await JSHelpers.Alert(exc.Message);
                    }
                }
                else
                {
                    // Handle expected guid
                }
            }
            else
            {
                client = new AddClientProfile()
                {
                    Address = new Address()
                };
            }

            try
            {
                organizations = await OrganizationsClient.GetOrganizationsAsync();
            }

            /* catch (ApiException exc)
             * {
             * }
             * catch (HttpRequestException exc)
             * {
             * } */
            catch (Exception exc)
            {
                await JSHelpers.Alert(exc.Message);
            }

            try
            {
                managers = await ManagersClient.GetManagersAsync(null);
            }

            /* catch (ApiException exc)
             * {
             * }
             * catch (HttpRequestException exc)
             * {
             * } */
            catch (Exception exc)
            {
                await JSHelpers.Alert(exc.Message);
            }
        }