public virtual void Configure(IApplicationBuilder aspNetCoreApp) { if (aspNetCoreApp == null) { throw new ArgumentNullException(nameof(aspNetCoreApp)); } aspNetCoreApp.Map("/ClientAppProfile", innerAspNetCoreApp => { innerAspNetCoreApp.UseXContentTypeOptions(); innerAspNetCoreApp.UseMiddleware <AspNetCoreNoCacheResponseMiddleware>(); innerAspNetCoreApp.Run(async context => { if (context == null) { throw new ArgumentNullException(nameof(context)); } IClientProfileModelProvider clientProfileModelProvider = context.RequestServices.GetService <IClientProfileModelProvider>(); ClientProfileModel clientProfileModel = await clientProfileModelProvider.GetClientProfileModelAsync(context.RequestAborted).ConfigureAwait(false); string clientAppProfileJson = clientProfileModel.ToJavaScriptObject(); context.Response.ContentType = "text/javascript; charset=utf-8"; await context.Response.WriteAsync(clientAppProfileJson, context.RequestAborted).ConfigureAwait(false); }); }); }
public virtual void Configure(IAppBuilder owinApp) { if (owinApp == null) { throw new ArgumentNullException(nameof(owinApp)); } owinApp.Map("/ClientAppProfile", innerOwinApp => { innerOwinApp.UseXContentTypeOptions(); innerOwinApp.Use <OwinNoCacheResponseMiddleware>(); innerOwinApp.Run(async context => { if (context == null) { throw new ArgumentNullException(nameof(context)); } IDependencyResolver dependencyResolver = context.GetDependencyResolver(); IClientProfileModelProvider clientProfileModelProvider = dependencyResolver.Resolve <IClientProfileModelProvider>(); ClientProfileModel clientProfileModel = await clientProfileModelProvider.GetClientProfileModelAsync(context.Request.CallCancelled); string clientAppProfileJson = clientProfileModel.ToJavaScriptObject(); context.Response.ContentType = "text/javascript; charset=utf-8"; await context.Response.WriteAsync(clientAppProfileJson, context.Request.CallCancelled); }); }); }
public bool SaveClientEdits(ClientProfileModel clientProfileModel) { ClientProfile existingClient = this.Repository.Single <ClientProfile>(x => x.id_client == (int)clientProfileModel.ClientId); this.Repository.Dispose(); ClientProfile clientProfile = Mapper.Map <ClientProfile>(clientProfileModel); //properties that dont change clientProfile.created_at = existingClient.created_at; clientProfile.id_client = existingClient.id_client; clientProfile.deleted_on = existingClient.deleted_on; clientProfile.client_name = clientProfileModel.ClientName; clientProfile.fk_state = clientProfileModel.StateId; clientProfile.zip_4 = clientProfileModel.Zip4; clientProfile.fk_company_location = clientProfileModel.CompanyLocationId; clientProfile.updated_at = DateTime.Now; clientProfile.FillInNulls(); this.Repository.NewContext(); this.Repository.Modify(clientProfile); this.Repository.CommitAndDispose(); return(true); }
public static string GetClientState(int UserCredentialsID) { ClientProfileModel data = new ClientProfileModel { UserCredentialsID = UserCredentialsID }; string sql = @"SELECT State FROM dbo.ClientInformation WHERE UserCredentialsId = @UserCredentialsID;"; return(sqlDataAccess.GetInfo(sql, data)); }
public async Task <ActionResult> UpdateClientFullProfile([FromBody] ClientProfileModel clientProfileModel) => await Exec(async operation => { var(_, id) = VerifyUser(UserRole.Client); if (!ModelState.IsValid) { throw new Exception(ExceptionMessage.ModelIsInvalid); } var entity = clientProfileModel.ToEntity(id); await clientProfileService.UpdateClientFullProfile(operation, entity); });
public void PostCreate() { ClientProfileModel clientProfileModel = new ClientProfileModel(); clientProfileModel.ClientName = "Hello"; clientProfileModel.CompanyLocationId = 1; ActionResult result = controller.Create(clientProfileModel); Assert.IsNotNull(result); }
public virtual string GetIndexPageHtmlContents(string htmlPage) { if (htmlPage == null) { throw new ArgumentNullException(nameof(htmlPage)); } ClientProfileModel clientProfileModel = ClientProfileModelProvider.GetClientProfileModel(); return(ReplaceDefinedVariables(htmlPage, clientProfileModel)); }
public virtual async Task <string> GetHtmlPageAsync(string htmlPage, CancellationToken cancellationToken) { if (htmlPage == null) { throw new ArgumentNullException(nameof(htmlPage)); } ClientProfileModel clientProfileModel = await ClientProfileModelProvider.GetClientProfileModelAsync(cancellationToken).ConfigureAwait(false); return(ReplaceDefinedVariables(htmlPage, clientProfileModel)); }
public ClientProfileModel SendRequestUpdateProfileInformation(ClientProfileModel updateProfileModel) { var response = new RestRequestBuilder(NewBookModelsUrl.GetBaseUrl("1"), NewBookModelsUrl.Profile.Update()) .AddParametersAsJsonRowInRequestBody(updateProfileModel) .AddMethodType(Method.PATCH) .AddHeader("content-type", "application/json") .AddHeader("authorization", Context.Token) .AddRequestFormat(DataFormat.Json) .Execute(); return(JsonConvert.DeserializeObject <ClientProfileModel>(response.Content)); }
private string ReplaceDefinedVariables(string htmlPage, ClientProfileModel clientProfileModel) { return(htmlPage .Replace("{{model.AppVersion}}", clientProfileModel.AppVersion, StringComparison.InvariantCultureIgnoreCase) .Replace("{{model.AppName}}", clientProfileModel.AppName, StringComparison.InvariantCultureIgnoreCase) .Replace("{{model.DebugMode}}", clientProfileModel.DebugMode.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(), StringComparison.InvariantCultureIgnoreCase) .Replace("{{model.BaseHref}}", clientProfileModel.BaseHref, StringComparison.InvariantCultureIgnoreCase) .Replace("{{model.Title}}", clientProfileModel.AppTitle, StringComparison.InvariantCultureIgnoreCase) .Replace("{{model.Theme}}", clientProfileModel.Theme, StringComparison.InvariantCultureIgnoreCase) .Replace("{{model.Culture}}", clientProfileModel.Culture, StringComparison.InvariantCultureIgnoreCase) .Replace("{{model.TimeZone}}", clientProfileModel.DesiredTimeZoneValue, StringComparison.InvariantCultureIgnoreCase) .Replace("<script src=\"ClientAppProfile\" type=\"text/javascript\"></script>", clientProfileModel.ToJavaScriptTag(), StringComparison.InvariantCultureIgnoreCase)); }
public ActionResult Create(ClientProfileModel model) { if (ModelState.IsValid) { HttpCookie cookie = Request.Cookies["UserInfo"]; if (cookie != null) { model.UserCredentialsID = Int32.Parse(cookie["UserID"]); } ClientProfileProcessor.InsertClientInformation(model.FullName, model.Address1, model.Address2, model.City, model.State, model.Zipcode, model.UserCredentialsID); return(RedirectToAction("Index", "Client")); } return(View()); }
public ActionResult EditClientProfile(string Email) { UserDTO userDto = new UserDTO(); try { userDto = UserService.Find(Email); } catch (NullReferenceException ex) { return(RedirectToAction("Login")); } ClientProfileModel clientProfile = ReturnClientProfile(userDto); return(View("ClientProfile", clientProfile)); }
public ActionResult Create(ClientProfileModel clientProfileM) { if (ModelState.IsValid) { this.ClientProfileVMService.SaveNewClient(clientProfileM); return(RedirectToAction("Manage", new { alertTitle = "Success", alertType = "success", alertMessage = "New Client Created" })); } return(View(clientProfileM)); }
public virtual async Task <ClientProfileModel> GetClientProfileModelAsync(CancellationToken cancellationToken) { ClientProfileModel clientAppProfileModel = new ClientProfileModel { AppVersion = AppEnvironment.AppInfo.Version, DebugMode = AppEnvironment.DebugMode, AppName = AppEnvironment.AppInfo.Name }; UserSetting userSetting = UsersSettingsProvider == null ? null : await UsersSettingsProvider.GetCurrentUserSettingAsync(cancellationToken).ConfigureAwait(false); string theme = userSetting?.Theme ?? AppEnvironment.AppInfo.DefaultTheme; string culture = userSetting?.Culture ?? AppEnvironment.AppInfo.DefaultCulture; string desiredTimeZone = userSetting?.DesiredTimeZone ?? AppEnvironment.AppInfo.DefaultTimeZone; string desiredTimeZoneValue = null; if (culture == null || string.Equals(culture, "Auto", StringComparison.OrdinalIgnoreCase)) { culture = "EnUs"; } if (desiredTimeZone != null && !string.Equals(desiredTimeZone, "Auto", StringComparison.CurrentCulture)) { desiredTimeZoneValue = desiredTimeZone; } string appTitle = AppEnvironment.Cultures.Any() ? AppEnvironment.Cultures .ExtendedSingle($"Finding culture {culture} in environment {AppEnvironment.Name}", c => c.Name == culture).Values.ExtendedSingle($"Finding AppTitle in culture {culture}", v => string.Equals(v.Name, "AppTitle", StringComparison.OrdinalIgnoreCase)).Title : string.Empty; clientAppProfileModel.AppTitle = appTitle; clientAppProfileModel.Culture = culture; clientAppProfileModel.DesiredTimeZoneValue = desiredTimeZoneValue; clientAppProfileModel.Theme = theme; clientAppProfileModel.EnvironmentConfigsJson = ContentFormatter.Serialize(AppEnvironment .Configs.Where(c => c.AccessibleInClientSide == true) .Select(c => new { value = c.Value, key = c.Key })); clientAppProfileModel.BaseHref = AppEnvironment.GetHostVirtualPath(); return(clientAppProfileModel); }
public bool SaveNewClient(ClientProfileModel clientProfileModel) { //build ClientProfile clientProfile = Mapper.Map <ClientProfile>(clientProfileModel); clientProfile.fk_company_location = clientProfileModel.CompanyLocationId; clientProfile.fk_state = clientProfileModel.StateId; clientProfile.created_at = DateTime.Now; clientProfile.updated_at = DateTime.Now; clientProfile.FillInNulls(); //save this.Repository.Add(clientProfile); this.Repository.CommitAndDispose(); return(true); }
//--------------------------------------- private ClientProfileModel ReturnClientProfile(UserDTO userDto) { ClientProfileModel clientProfile = new ClientProfileModel(); clientProfile.ID = userDto.Id; clientProfile.Avatar_path = userDto.avatar_path; clientProfile.City = userDto.city; clientProfile.Date_of_registration = userDto.date_of_registration; clientProfile.Email = userDto.Email; clientProfile.Password = userDto.password; clientProfile.Info = userDto.info; clientProfile.Name = userDto.name; clientProfile.Nickname = userDto.nickname; clientProfile.Sername = userDto.sername; return(clientProfile); }
public async Task <ActionResult> EditClientProfile(ClientProfileModel model, HttpPostedFileBase upload, string info) { string new_avatar_path = model.Avatar_path; string fileName = ""; if (upload != null) { fileName = System.IO.Path.GetFileName(upload.FileName); // сохраняем файл в папку Images в проекте upload.SaveAs(Server.MapPath("~/Images/" + model.ID + ".jpg")); } if (fileName != "") { new_avatar_path = "~/Images/" + fileName; } await SetInitialDataAsync(); if (ModelState.IsValid) { UserDTO userDto = new UserDTO { UserId = model.ID, Email = model.Email, password = model.Password, city = model.City, name = model.Name, sername = model.Sername, role = "user", nickname = model.Nickname, date_of_registration = model.Date_of_registration, avatar_path = new_avatar_path, info = info }; OperationDetails operationDetails = await UserService.Update(userDto); if (operationDetails.Succedeed) { return(RedirectToAction("ClientProfile", new { Email = userDto.Email })); } else { ModelState.AddModelError(operationDetails.Property, operationDetails.Message); } } return(View(model)); }
public List <ClientProfileModel> GetClients(int companyLocationId) { List <ClientProfile> listClientProfiles = this.Repository.Many <ClientProfile>(x => true).ToList(); List <ClientProfileModel> listClientProfileVMs = new List <ClientProfileModel>(); foreach (var clientProfile in listClientProfiles) { ClientProfileModel clientProfileModel = Mapper.Map <ClientProfileModel>(clientProfile); clientProfileModel.ClientName = clientProfile.client_name; clientProfileModel.ClientId = clientProfile.id_client; clientProfileModel.Deleted = clientProfile.deleted_on != null; listClientProfileVMs.Add(clientProfileModel); } return(listClientProfileVMs); }
public static int InsertClientInformation(string fullname, string add1, string add2, string city, string state, string zipcode, int usercredentialsId) { ClientProfileModel data = new ClientProfileModel { FullName = fullname, Address1 = add1, Address2 = add2, City = city, State = state, Zipcode = zipcode, UserCredentialsID = usercredentialsId }; string sql = @"insert into ClientInformation (FullName, Address1, Address2, City,State,Zipcode,UserCredentialsID) values(@Fullname, @Address1, @Address2,@City, @State, @Zipcode,@UserCredentialsID);"; return(sqlDataAccess.SaveData(sql, data)); }
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); }
public virtual string GetIndexPageHtmlContents(string htmlPage) { ClientProfileModel clientProfileModel = ClientProfileModelProvider.GetClientProfileModel(); return(ReplaceDefinedVariables(htmlPage, clientProfileModel)); }
public virtual async Task <string> GetHtmlPageAsync(string htmlPage, CancellationToken cancellationToken) { ClientProfileModel clientProfileModel = await ClientProfileModelProvider.GetClientProfileModelAsync(cancellationToken); return(ReplaceDefinedVariables(htmlPage, clientProfileModel)); }
public ActionResult Edit([Bind(Prefix = "ClientProfileM")] ClientProfileModel clientProfileModel, string buttonClicked) { string redirectAction = "Manage"; string alertType = ""; string alertMessage = ""; bool redirect = false; //to archive if (buttonClicked == "Archive") { bool wasArchived = this.ClientProfileVMService.ArchiveClient((int)clientProfileModel.ClientId); if (wasArchived) { redirect = true; alertType = "success"; alertMessage = clientProfileModel.ClientName + " archived."; } else { redirect = true; alertType = "error"; alertMessage = clientProfileModel.ClientName + " could not be archived."; } } //to restore if (buttonClicked == "Unarchive") { bool wasUnarchived = this.ClientProfileVMService.UnarchiveClient((int)clientProfileModel.ClientId); if (wasUnarchived) { redirect = true; alertType = "success"; alertMessage = clientProfileModel.ClientName + " was restored."; } else { redirect = true; alertType = "error"; alertMessage = clientProfileModel.ClientName + " could not be restored"; } } if (ModelState.IsValid && buttonClicked == "") { this.ClientProfileVMService.SaveClientEdits(clientProfileModel); redirect = true; } //--redirect if (redirect) { return(RedirectToAction(redirectAction, new { alertType = alertType, alertMessage = alertMessage })); } return(View(clientProfileModel)); }