public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,Name,Content,Url")] UserWebsite userWebsite) { if (id != userWebsite.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userWebsite); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserWebsiteExists(userWebsite.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userWebsite)); }
public UserWebsiteProxy Website_GetUserWebsiteInfo(int userID, int websiteID) { if (!CheckClient()) { return(null); } UserWebsite userwebsite = WebsiteBO.Instance.GetUserWebsite(userID, websiteID); return(ProxyConverter.GetUserWebsiteProxy(userwebsite)); }
public async Task <IActionResult> Create([Bind("Id,UserId,Name,Content,Url")] UserWebsite userWebsite) { if (ModelState.IsValid) { _context.Add(userWebsite); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userWebsite)); }
//WebsiteUser Table services //add a websiteId and UserId to one another public static void AddUserToWebsite(UserWebsite model) { DataProvider.ExecuteNonQuery(GetConnection, "dbo.UserWebsite_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@UserId", model.UserId); SqlParameter s = new SqlParameter("@WebsiteIds", SqlDbType.Structured); if (model.WebsiteIds != null && model.WebsiteIds.Any()) { s.Value = new IntIdTable(model.WebsiteIds); } paramCollection.Add(s); }); }
public override UserWebsite AdminGetUserWebsite(int userWebsiteID) { using (SqlQuery query = new SqlQuery()) { query.CommandType = CommandType.Text; query.CommandText = "SELECT * FROM Chinaz_UserWebsitesView WHERE UserWebsiteID = @UserWebsiteID"; query.CreateParameter <int>("@UserWebsiteID", userWebsiteID, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { UserWebsite result = null; while (reader.Next) { result = new UserWebsite(reader); } return(result); } } }
public List <UserWebsite> GetWebsiteId() { List <UserWebsite> userWebsite = new List <UserWebsite>(); DataProvider.ExecuteCmd(GetConnection, "dbo.UserWebsite_SelectAll" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { }, map : delegate(IDataReader reader, short set) { UserWebsite uw = new UserWebsite(); int startingIndex = 0; uw.UserId = reader.GetSafeString(startingIndex++); uw.WebsiteId = reader.GetSafeInt32(startingIndex++); userWebsite.Add(uw); } ); return(userWebsite); }
public override UserWebsite CreateUserWebsite(int userID, int categoryID, string url, string websiteName, string verifyFilename, string websiteIntro) { using (SqlQuery query = new SqlQuery()) { query.CommandType = CommandType.StoredProcedure; query.CommandText = "bx_Chinaz_CreateWebsiteItem"; query.CreateParameter <int>("@UserID", userID, SqlDbType.Int); query.CreateParameter <string>("@Url", url, SqlDbType.NVarChar, 200); query.CreateParameter <int>("@CategoryID", categoryID, SqlDbType.Int); query.CreateParameter <string>("@WebsiteName", websiteName, SqlDbType.NVarChar, 50); query.CreateParameter <string>("@VerifyFilename", verifyFilename, SqlDbType.VarChar, 50); query.CreateParameter <string>("@WebsiteIntro", websiteIntro, SqlDbType.NVarChar, 200); using (XSqlDataReader reader = query.ExecuteReader()) { UserWebsite item = null; while (reader.Next) { item = new UserWebsite(reader); } return(item); } } }
//Service ran for creating a new user - pass in users id and request model public void CreateUserProfile(string userId, CreateUserRequest model) { //Updated the create user so that it can take in the tokenHash param if there is one provided DataProvider.ExecuteNonQuery(GetConnection, "UserProfiles_Insert" // stored procedure , inputParamMapper : delegate(SqlParameterCollection paramCollection) { //input fields paramCollection.AddWithValue("@UserId", userId); paramCollection.AddWithValue("@FirstName", model.FirstName); paramCollection.AddWithValue("@LastName", model.LastName); paramCollection.AddWithValue("@TokenHash", model.TokenHash); //this is provided if they were referred by a current customer } ); //referral coupon //if TokenHash referral is null, they're making a new account. //if TokenHash referral is NOT null, we want to give them (new user) a Coupon value and add it to their Credit. // we also want to give the original user (one who referred) the same Coupon value and add it to their Credit. if (model.TokenHash != null) { //retrieve coupon information + token information based on the token hash. CouponsDomain userCoupon = TokenService.GetReferralTokenByGuid(model.TokenHash); if (userCoupon.Token.Used == null) { //send token to Credit service UserCreditsRequest insertRefferalCredits = new UserCreditsRequest(); UserCreditsRequest insertFriendCredits = new UserCreditsRequest(); //send credits to new User who was referred insertRefferalCredits.Amount = userCoupon.CouponValue; insertRefferalCredits.TransactionType = "Add"; insertRefferalCredits.UserId = userId; _CreditsService.InsertUserCredits(insertRefferalCredits); } else { //send error message that token has already been used. } } //Activity Services ActivityLogRequest Activity = new ActivityLogRequest(); Activity.ActivityType = ActivityTypeId.NewAccount; _ActivityLogService.InsertActivityToLog(userId, Activity); //----------//create a new Website Id ---------updated the AddUserToWebsite using the updated domain with int[] //getting the websiteId via the website Slug Website w = null; string Slug = model.Slug; w = WebsiteService.GetWebsiteIdBySlug(Slug); int[] WebsiteIds = new int[1]; WebsiteIds[0] = w.Id; //populating userwebsite object UserWebsite userWebsite = new UserWebsite(); userWebsite.UserId = userId; userWebsite.WebsiteIds = WebsiteIds; WebsiteService.AddUserToWebsite(userWebsite); //creae a new Customer role //set role as customer by default - change role by admin panel UserProfile aspUser = new UserProfile(); aspUser.FirstName = model.FirstName; aspUser.LastName = model.LastName; aspUser.RoleId = ConfigService.CustomerRole; _AdminService.CreateUserRole(userId, aspUser); //create a new Braintree account using UserID //braintree used for handling credit card transactions CustomerPaymentRequest Payment = new CustomerPaymentRequest(); Payment.FirstName = model.FirstName; Payment.LastName = model.LastName; Payment.UserId = userId; Payment.Phone = model.Phone; //Send a confirmation Text Msg string UserSMSToken = TokenSMSService.TokenSMSInsert(userId); //send a text msg NotifySMSRequest NotifyCustomer = new NotifySMSRequest(); NotifyCustomer.Phone = model.Phone; NotifyCustomer.TokenSMS = UserSMSToken; try { NotifySMSService.SendConfirmText(NotifyCustomer); } catch (ArgumentException ex) { //if phone number is already registered will not send a registration check //should never get this far throw new System.ArgumentException(ex.Message); } //bringg create account RegisterBringgRequest bringgRequest = new RegisterBringgRequest(); bringgRequest.Name = model.FirstName + " " + model.LastName; bringgRequest.Phone = model.Phone; bringgRequest.Email = model.Email; bringgRequest.UserId = userId; this._CreateCustomerTask.Execute(bringgRequest); _CreateCustomerTask.Execute(bringgRequest); BrainTreeService brainTree = new BrainTreeService(); brainTree.newCustomerInsert(Payment); ////generate a new token Guid userTokenGuid = TokenService.tokenInsert(userId); //send a confirmation email _EmailService.SendProfileEmail(userTokenGuid, model.Email); }
/// <summary> /// 获取用户网站列表信息 /// </summary> /// <param name="userID"></param> /// <param name="pageSize"></param> /// <param name="isGetMessages">是否获取消息列表</param> /// <param name="isGetServices">是否获取服务列表</param> /// <param name="pageNumber"></param> /// <returns></returns> public override UserWebsiteCollection GetUserWebsites(int userID, int pageSize, int pageNumber, bool isGetMessages, bool isGetServices) { using (SqlQuery query = new SqlQuery()) { query.Pager.TableName = "Chinaz_UserWebsitesView"; query.Pager.PageSize = pageSize; query.Pager.PageNumber = pageNumber; query.Pager.PrimaryKey = "UserWebsiteID"; query.Pager.SelectCount = true; query.Pager.SortField = "UserWebsiteID"; query.Pager.IsDesc = true; query.Pager.Condition = "UserID = @UserID"; query.CreateParameter <int>("@UserID", userID, SqlDbType.Int); UserWebsiteCollection result = new UserWebsiteCollection(); using (XSqlDataReader reader = query.ExecuteReader()) { result = new UserWebsiteCollection(reader); if (reader.NextResult()) { while (reader.Next) { result.TotalRecords = reader.Get <int>(0); } } } if (isGetMessages || isGetServices) { query.CommandText = ""; if (isGetMessages) { if (result.Count > 0) { WebsiteService service = null; string url; foreach (UserWebsite web in result) { for (int i = 0; i < WebsiteServiceList.ServiceList.Count; i++) { service = WebsiteServiceList.ServiceList[i]; url = RemoveUrlPrefix(web.Url); web.Services.Add(service.ID, new WebsiteService(service.ID, service.Content, string.Format(service.Url, url), service.LightImgPath, service.UnLightImgPath, service.IsPreView, service.OnLight)); } } } } if (isGetMessages) { query.CommandText += "SELECT * FROM Chinaz_UserWebsiteMessages WHERE UserWebsiteID IN(@UserWebsiteIDs) Order BY UserWebsiteID;"; } if (isGetServices) { query.CommandText += "SELECT * FROM Chinaz_UserWebsiteServices WHERE UserWebsiteID IN(@UserWebsiteIDs) Order BY UserWebsiteID;"; } query.CommandType = CommandType.Text; query.CreateInParameter <int>("@UserWebsiteIDs", result.GetKeys()); using (XSqlDataReader reader = query.ExecuteReader()) { UserWebsite site = null; if (isGetMessages) { while (reader.Next) { UserWebsiteMessage message = new UserWebsiteMessage(reader); if (site != null && site.UserWebsiteID == message.UserWebsiteID) { site.Messages.Add(message); } else { site = result.GetValue(message.UserWebsiteID); site.Messages.Add(message); } } } if (isGetServices) { if (isGetMessages == false) { reader.NextResult(); } int websiteid, serviceid; while (reader.Next) { serviceid = reader.Get <int>("ServiceID"); websiteid = reader.Get <int>("UserWebsiteID"); if (site != null && site.UserWebsiteID == websiteid) { site.Services[serviceid].OnLight = true; } else { site = result.GetValue(websiteid); site.Services[serviceid].OnLight = true; } } } } } return(result); } }
public void CreateUserProfile(string userId, CreateUserRequest model) { //Updated the create user so that it can take in the tokenHash param if there is one provided --Anna DataProvider.ExecuteNonQuery(GetConnection, "UserProfiles_Insert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@UserId", userId); paramCollection.AddWithValue("@FirstName", model.FirstName); paramCollection.AddWithValue("@LastName", model.LastName); paramCollection.AddWithValue("@TokenHash", model.TokenHash); //this is provided if they were referred by a current customer } ); //referral coupon //if TokenHash referral is null, they're making a new account. //if TokenHash referral is NOT null, give new user a Coupon value and add it to their Credit. // we also want to give the original user (one who referred) the same Coupon value and add it to their Credit. if (model.TokenHash != null) { //retrieve coupon information + token information based on the token hash. CouponsDomain userCoupon = TokenService.GetReferralTokenByGuid(model.TokenHash); if (userCoupon.Token.Used == null) { //send token to Credit service UserCreditsRequest insertRefferalCredits = new UserCreditsRequest(); //send credits to new User who was referred insertRefferalCredits.Amount = userCoupon.CouponValue; insertRefferalCredits.TransactionType = "Add"; insertRefferalCredits.UserId = userId; _CreditsService.InsertUserCredits(insertRefferalCredits); //send credits to Friend who referred new user BUT ONLY AFTER THE REFERRED FRIEND HAS COMPLETED THEIR FIRST ORDER---- //see BrainTreeService, Line 130 } } //Activity Services - update the activity log ActivityLogRequest Activity = new ActivityLogRequest(); Activity.ActivityType = ActivityTypeId.NewAccount; _ActivityLogService.InsertActivityToLog(userId, Activity); //Associating a User to website(s) Website w = null; string Slug = model.Slug; w = WebsiteService.GetWebsiteIdBySlug(Slug); int[] WebsiteIds = new int[1]; WebsiteIds[0] = w.Id; UserWebsite userWebsite = new UserWebsite(); userWebsite.UserId = userId; userWebsite.WebsiteIds = WebsiteIds; WebsiteService.AddUserToWebsite(userWebsite); //creae a new Customer role UserProfile aspUser = new UserProfile(); aspUser.FirstName = model.FirstName; aspUser.LastName = model.LastName; aspUser.RoleId = ConfigService.CustomerRole; _AdminService.CreateUserRole(userId, aspUser); //create a new Braintree account using UserID CustomerPaymentRequest Payment = new CustomerPaymentRequest(); Payment.FirstName = model.FirstName; Payment.LastName = model.LastName; Payment.UserId = userId; Payment.Phone = model.Phone; //Send a confirmation Text Msg string UserSMSToken = TokenSMSService.TokenSMSInsert(userId); //send a text msg NotifySMSRequest NotifyCustomer = new NotifySMSRequest(); NotifyCustomer.Phone = model.Phone; NotifyCustomer.TokenSMS = UserSMSToken; try { NotifySMSService.SendConfirmText(NotifyCustomer); } catch (ArgumentException /*ex*/) { DeleteUserProfileByUserId(userId); DeleteUserWebsiteByUserId(userId); DeleteAspNetUserByUserId(userId); throw new System.ArgumentException(ex.Message); } //send a confirmation email _EmailService.SendProfileEmail(userTokenGuid, model.Email); //bringg create account RegisterBringgRequest bringgRequest = new RegisterBringgRequest(); bringgRequest.Name = model.FirstName + " " + model.LastName; bringgRequest.Phone = model.Phone; bringgRequest.Email = model.Email; bringgRequest.UserId = userId; this._CreateCustomerTask.Execute(bringgRequest); _CreateCustomerTask.Execute(bringgRequest); BrainTreeService brainTree = new BrainTreeService(); brainTree.newCustomerInsert(Payment); ////generate a new token Guid userTokenGuid = TokenService.tokenInsert(userId); //send a confirmation email _EmailService.SendProfileEmail(userTokenGuid, model.Email, model.Slug); }
public override UserWebsite CreateUserWebsite(int userID, int categoryID, string url, string websiteName, string verifyFilename, string websiteIntro) { using (SqlQuery query = new SqlQuery()) { query.CommandType = CommandType.StoredProcedure; query.CommandText = "bx_Chinaz_CreateWebsiteItem"; query.CreateParameter<int>("@UserID", userID, SqlDbType.Int); query.CreateParameter<string>("@Url", url, SqlDbType.NVarChar, 200); query.CreateParameter<int>("@CategoryID", categoryID, SqlDbType.Int); query.CreateParameter<string>("@WebsiteName", websiteName, SqlDbType.NVarChar, 50); query.CreateParameter<string>("@VerifyFilename", verifyFilename, SqlDbType.VarChar, 50); query.CreateParameter<string>("@WebsiteIntro", websiteIntro, SqlDbType.NVarChar, 200); using (XSqlDataReader reader = query.ExecuteReader()) { UserWebsite item = null; while (reader.Next) item = new UserWebsite(reader); return item; } } }
public override UserWebsite AdminGetUserWebsite(int userWebsiteID) { using (SqlQuery query = new SqlQuery()) { query.CommandType = CommandType.Text; query.CommandText = "SELECT * FROM Chinaz_UserWebsitesView WHERE UserWebsiteID = @UserWebsiteID"; query.CreateParameter<int>("@UserWebsiteID", userWebsiteID, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { UserWebsite result = null; while (reader.Next) { result = new UserWebsite(reader); } return result; } } }