public OperationResultVo <Guid> Add(Guid userId, Guid contentId, string title, string introduction) { try { FeaturedContent newFeaturedContent = new FeaturedContent { UserContentId = contentId }; UserContent content = userContentDomainService.GetById(contentId); newFeaturedContent.Title = string.IsNullOrWhiteSpace(title) ? content.Title : title; newFeaturedContent.Introduction = string.IsNullOrWhiteSpace(introduction) ? content.Introduction : introduction; newFeaturedContent.ImageUrl = string.IsNullOrWhiteSpace(content.FeaturedImage) || content.FeaturedImage.Equals(Constants.DefaultFeaturedImage) ? Constants.DefaultFeaturedImage : UrlFormatter.Image(content.UserId, ImageType.FeaturedImage, content.FeaturedImage); newFeaturedContent.FeaturedImage = content.FeaturedImage; newFeaturedContent.StartDate = DateTime.Now; newFeaturedContent.Active = true; newFeaturedContent.UserId = userId; newFeaturedContent.OriginalUserId = content.UserId; featuredContentDomainService.Add(newFeaturedContent); unitOfWork.Commit(); return(new OperationResultVo <Guid>(newFeaturedContent.Id)); } catch (Exception ex) { return(new OperationResultVo <Guid>(ex.Message)); } }
public ActionResult Add(string def, string catagory, string exa, string keyword) { UserContent rawdata = new UserContent(); rawdata.UserId = (Guid)Membership.GetUser().ProviderUserKey; rawdata.Catagory = !String.IsNullOrEmpty(catagory) ? catagory : ""; rawdata.Keyword = !String.IsNullOrEmpty(keyword) ? keyword : ""; rawdata.Def = !String.IsNullOrEmpty(def) ? def : ""; rawdata.Exa = !String.IsNullOrEmpty(exa) ? exa : ""; rawdata.DateAdd = DateTime.Now; string message = ""; AddContentModel model = new AddContentModel(); if (model.Add(rawdata) > 0) { message = "SUCCESS"; } else { message = "FAIL"; } return(Json(new { message = message })); }
public ActionResult DeleteConfirmed(int id) { UserContent userContent = db.UserContents.Find(id); db.UserContents.Remove(userContent); db.SaveChanges(); return RedirectToAction("Index"); }
public string BlogFaveComment(int userID, string postGuid) { SueetieBlogComment sueetieBlogComment = SueetieBlogs.GetSueetieBlogComment(postGuid); if (userID > 0) { if (sueetieBlogComment.SueetieCommentID > 0) { string result = "You tagged this comment by " + sueetieBlogComment.Author + " as a favorite!"; UserContent userContent = new UserContent { ContentID = sueetieBlogComment.ContentID, UserID = userID }; int favoriteID = SueetieUsers.CreateFavorite(userContent); if (favoriteID < 0) { result = "You already tagged this comment as a favorite."; } return(result); } else { return("Sorry, we added favorites after this comment was written. Please consider tagging more recent comments as favorites."); } } else { return("Please login or become a member to tag this comment as a favorite"); } }
protected void LoginClick(object sender, EventArgs e) { lblError.Text = string.Empty; UserContent ucontent = new UserContent(); alamaat_User user = ucontent.GetbyUsername(UserName.Text); if (user != null) { if (user.password == Password.Text) { Session["alamaat_User"] = user; Response.Redirect("~/registration.aspx"); } else { lblError.Text = "Username or Password is incorrect."; return; } } else { lblError.Text = "Username or Password is incorrect."; return; } }
/// <summary> /// Выполнить вход пользователя в систему /// </summary> /// <remarks>Если пароль равен null, то он не проверяется</remarks> public bool Login(string username, string password, out string errMsg) { username = username == null ? "" : username.Trim(); int roleID; AppData.Refresh(); if (AppData.CheckUser(username, password, password != null, out roleID, out errMsg)) { LoggedOn = true; LogonDT = DateTime.Now; // заполнение свойств пользователя UserProps = new UserProps(); UserProps.UserID = AppData.DataAccess.GetUserID(username); UserProps.UserName = username; UserProps.RoleID = roleID; UserProps.RoleName = AppData.DataAccess.GetRoleName(roleID); if (password == null) { AppData.Log.WriteAction(string.Format(Localization.UseRussian ? "Вход в систему без пароля: {0} ({1}). IP-адрес: {2}" : "Login without a password: {0} ({1}). IP address: {2}", username, UserProps.RoleName, IpAddress)); } else { AppData.Log.WriteAction(string.Format(Localization.UseRussian ? "Вход в систему: {0} ({1}). IP-адрес: {2}" : "Login: {0} ({1}). IP address: {2}", username, UserProps.RoleName, IpAddress)); } UserRights userRights = new UserRights(); userRights.Init(roleID, AppData.DataAccess); UserRights = userRights; AppData.UserMonitor.AddUser(this); UpdateAppDataRefs(); RaiseOnUserLogin(); UserMenu = new UserMenu(AppData.Log); UserMenu.Init(this); UserViews = new UserViews(AppData.Log); UserViews.Init(this, AppData.DataAccess); UserContent = new UserContent(AppData.Log); UserContent.Init(this, AppData.DataAccess); return(true); } else { Logout(); AppData.Log.WriteError(string.Format(Localization.UseRussian ? "Неудачная попытка входа в систему: {0}{1}. IP-адрес: {2}" : "Unsuccessful login attempt: {0}{1}. IP address: {2}", username == "" ? "" : username + " - ", errMsg.TrimEnd('.'), IpAddress)); return(false); } }
public string BlogFavePost(int userID, string postGuid) { SueetieBlogPost sueetieBlogPost = SueetieBlogs.GetSueetieBlogPost(postGuid); if (userID > 0) { if (sueetieBlogPost.SueetiePostID > 0) { string result = "You have tagged " + sueetieBlogPost.Title + " as a favorite!"; UserContent userContent = new UserContent { ContentID = sueetieBlogPost.ContentID, UserID = userID }; int favoriteID = SueetieUsers.CreateFavorite(userContent); if (favoriteID < 0) { result = "You already tagged this post as a favorite."; } return(result); } else { return("Sorry, we added favorites after this post was published. Please consider tagging more recent posts as favorites."); } } else { return("Please login or become a member to tag this post as a favorite"); } }
//public static string SMSTest() //{ // SMS sms = new SMS(); // return sms.TestSMS(); //} public static List <RARTrans> PageTest(int pageIndex) { List <RARTrans> result = null; UserContent udb = new UserContent(); var ml = udb.GetMemberInfoByOpenId("999"); TransContent db = new TransContent(); var list = db.ARTransDbSet.Where(t => t.openId == "999").Join(db.MemberInfo, a => a.FromOpenId, b => b.openId, (a, b) => new RARTrans { ChildNickName = b.nickname, openId = a.openId, Amount = a.Amount, TransDateTime = a.TransDateTime, TransId = a.TransId, TransRemark = a.TransRemark }); int count = list.Count(); list = list.OrderBy(t => t.TransDateTime); result = list.Skip(pageIndex * 10).Take(10).ToList(); return(result); }
protected void UpdateClick(object sender, EventArgs e) { alamaat_User user = (alamaat_User)Session["alamaat_user"]; if (user != null) { user.firstname = tbfirstname.Text; user.middlename = tbmiddlename.Text; user.lastname = tblastname.Text; //user.UserName = UserName.Text; user.password = Password.Text; user.email = Email.Text; user.address = tbaddress.Text; user.city = tbcity.Text; user.province = tbprovince.Text; user.country = tbcountry.Text; user.postalcode = tbpCode.Text; user.phone = tbphone.Text; user.mobilephone = tbMobilephone.Text; user.fax = tbfax.Text; // user. = tbbirth.Text; UserContent ucontent = new UserContent(); if (ucontent.UpdateUser(user)) { lbloutput.Text = "Profile updated successfully."; } } }
protected void SaveClick(object sender, EventArgs e) { lblError.Text = ""; lbloutput.Text = ""; UserContent uContent = new UserContent(); UserInterface user = new UserInterface(); alamaat_User _user = uContent.GetbyUsername(UserName.Text); if (null != _user) { lblError.Text = "Username is not available."; UserName.Focus(); return; } alamaat_User useremail = uContent.GetuserByEmail(Email.Text); if (null != useremail) { lblError.Text = "A user is already registered with this email address. Please try another email address."; Email.Focus(); return; } user.ID = Guid.NewGuid(); user.FirstName = tbfirstname.Text; user.MiddleName = tbmiddlename.Text; user.LastName = tblastname.Text; user.UserName = UserName.Text; user.Password = Password.Text; user.Email = Email.Text; user.Address = tbaddress.Text; user.City = tbcity.Text; user.Province = tbprovince.Text; user.Country = tbcountry.Text; user.PCode = tbpCode.Text; user.Phone = tbphone.Text; user.MobilePhone = tbMobilephone.Text; user.Fax = tbfax.Text; user.BirthDate = tbbirth.Text; if (uContent.InsertUser(user)) { regpanel.Visible = false; lbloutput.Visible = true; string emailcontent = "Hello " + user.UserName + "," + "<br/><br/><b>Username:</b> " + user.UserName + "<br/><br/>Thank you for registering at Alamaat. Your account is created and must be activated before you can use it." + "<br/>To activate the account click on the following link or copy-paste it in your browser:" + "<br/>www.alamaat.biz/activation.aspx?id=" + user.ID + "<br/>After activation you may login to http://www.alamaat.biz/ using the following username and the password you entered during registration:"; if (SendEmail(user.Email, "Alamaat Account Details for " + user.UserName, emailcontent)) { lbloutput.Text = "An email has been sent to you to activate your account."; return; } else { lbloutput.Text = "Failed to send activation email. please contact admin at [email protected] or (+92)-333-5113213211."; return; } } }
public static void DBinit() { using (UserContent db = new UserContent()) { db.Get("111"); db.GetMemberInfoByOpenId("111"); } }
public ActionResult EditPost(int id) { if (Session["username"] == null) { return(RedirectToAction("SessionExpired")); } UserContent post = CRUD.GetUserPost(id); return(View(post)); }
public static void TemplateTest() { using (UserContent db = new UserContent()) { EUserInfo ui = db.Get("11"); int i = 1; } //string template =JsonConvert.SerializeObject(data); }
public bool AddUserContent(string login, RssChannel rssChannel, string catalog) { UserContent userContent; using (_db = new ApplicationContext()) { var userId = _db.Users.Where(u => u.Login == login).Select(p => p.Id).First(); var rssCh = _db.RssChanels.FirstOrDefault(rs => rs.Title == rssChannel.Title); if (rssCh == null) { userContent = new UserContent { UserId = userId, Category = catalog, RssChannel = rssChannel }; } else { userContent = _db.UserContents.Where(rs => rs.Category == catalog && rs.RssChannelId == rssCh.Id && rs.UserId == userId).FirstOrDefault(); if (userContent != null) { userContent.RssChannel = rssCh; _db.SaveChanges(); return(false); } else { userContent = new UserContent { UserId = userId, Category = catalog, RssChannelId = rssCh.Id }; } } _db.UserContents.Add(userContent); try { _db.SaveChanges(); } catch { } } return(true); }
public async Task DeleteAsync(CreateOrDeleteUserContentInput input) { var userContent = new UserContent { IdContent = input.IdContent, IdContentRelationType = input.IdContentRelationType, IdUser = input.IdUser }; _context.Entry(userContent).State = EntityState.Deleted; await _context.SaveChangesAsync(); }
public ActionResult SubmitPost(FormCollection formCollection, HttpPostedFileBase uploadImage) { UserContent newContent = new UserContent(); string text = formCollection["post-text-area"]; if (!string.IsNullOrEmpty(text)) { newContent.PostContent = text; } if (uploadImage != null) { string imageDirectory = ConfigurationManager.AppSettings.Get("ImageDirectory"); string pic = System.IO.Path.GetFileName(uploadImage.FileName); string path = System.IO.Path.Combine(Server.MapPath(imageDirectory), pic); if (System.IO.File.Exists(path)) { path = StoryService.Service.GetNewPathForFile(path); } uploadImage.SaveAs(path); newContent.PhotoName = System.IO.Path.GetFileName(path); } if (!String.IsNullOrEmpty(newContent.PostContent) || !String.IsNullOrEmpty(newContent.PhotoName)) { string userId = formCollection["user-id"]; string profileId = formCollection["profile-id"]; string grId = formCollection["group-id"]; int groupId; if (Int32.TryParse(grId, out groupId)) { ContentService.Service.AddNewContent(newContent, userId, profileId, groupId); } else { ContentService.Service.AddNewContent(newContent, userId, profileId, null); } } string controllerName = formCollection["controller-name"]; string actionName = formCollection["action-name"]; string routeValue = formCollection["route-value"]; if (String.IsNullOrEmpty(routeValue)) { return(RedirectToAction("Index", "Home")); } return(RedirectToAction(actionName, controllerName, new { id = routeValue })); }
public MainWindow() { InitializeComponent(); instance = this; UserLogin.initInstance(urlApi); UserContent.initInstance(urlApi); UserInscription.initInstance(urlApi); UserMesFilms.initInstance(urlApi); UserMesSeries.initInstance(urlApi); Navigator.Navigate(UserLogin.getInstance()); }
/// <summary> /// Deletes a user content /// </summary> /// <param name="content">User content</param> public virtual void DeleteUserContent(UserContent content) { if (content == null) { throw new ArgumentNullException("content"); } _contentRepository.Delete(content); //event notification _eventPublisher.EntityDeleted(content); }
public ActionResult Edit([Bind(Include = "UserContentId,UserId,ContentId")] UserContent userContent) { if (ModelState.IsValid) { db.Entry(userContent).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ContentId = new SelectList(db.Contents, "ContentId", "Text", userContent.ContentId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", userContent.UserId); return View(userContent); }
// GET: UserContents/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } UserContent userContent = db.UserContents.Find(id); if (userContent == null) { return HttpNotFound(); } return View(userContent); }
//public ActionResult Create([Bind(Include = "UserContentId,UserId,ContentId")] UserContent userContent) public ActionResult Create([Bind(Include = "UserId,ContentId")] UserContent userContent) { if (ModelState.IsValid) { db.UserContents.Add(userContent); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ContentId = new SelectList(db.Contents, "ContentId", "Text", userContent.ContentId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", userContent.UserId); return(View(userContent)); }
/// <summary> /// Выполнить вход пользователя в систему /// </summary> /// <remarks>Если пароль равен null, то он не проверяется</remarks> public bool Login(string username, string password, out string errMsg) { username = username == null ? "" : username.Trim(); AppData.Refresh(); if (AppData.CheckUser(username, password, password != null, out int roleID, out errMsg)) { LoggedOn = true; LogonDT = DateTime.Now; // заполнение свойств пользователя UserProps = new UserProps() { UserID = AppData.DataAccess.GetUserID(username), UserName = username, RoleID = roleID, RoleName = AppData.DataAccess.GetRoleName(roleID) }; if (password == null) { AppData.Log.WriteAction(string.Format(Localization.UseRussian ? "Вход в систему без пароля: {0} ({1}). IP-адрес: {2}" : "Login without a password: {0} ({1}). IP address: {2}", username, UserProps.RoleName, IpAddress)); } else { AppData.Log.WriteAction(string.Format(Localization.UseRussian ? "Вход в систему: {0} ({1}). IP-адрес: {2}" : "Login: {0} ({1}). IP address: {2}", username, UserProps.RoleName, IpAddress)); } UserRights userRights = new UserRights(AppData.ViewCache); userRights.Init(roleID, AppData.DataAccess); UserRights = userRights; AppData.UserMonitor.AddUser(this); StartPage = AppData.WebSettings.StartPage; // set start page by default UpdateAppDataRefs(); RaiseOnUserLogin(); UserMenu = new UserMenu(AppData.Log); UserMenu.Init(this); UserViews = new UserViews(AppData.ViewCache, AppData.Log); UserViews.Init(this, AppData.DataAccess); UserContent = new UserContent(AppData.Log); UserContent.Init(this, AppData.DataAccess); return(true); }
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["id"]; string sid = Request.QueryString["sid"]; if (id != null) { UserContent usercontent = new UserContent(); alamaat_User currentuser = usercontent.GetuserById(id); if (currentuser != null) { if (currentuser.block == false) { currentuser.active = true; if (usercontent.UpdateUser(currentuser)) { lblactivation.Text = "You have successfully activated your account."; } } else { lblactivation.Text = "User account is already activated."; } } } else if (sid != null) { SubscriberContent usercontent = new SubscriberContent(); alamaat_subscriber user = usercontent.Getuserbyid(sid); if (user != null) { if (user.active == false) { user.active = true; if (usercontent.UpdateSubscriber(user)) { lblactivation.Text = "You have successfully verified your email."; } } else { lblactivation.Text = "Email is already verified."; } } } else { Response.Redirect("~/Default.aspx"); } }
private void ActivatePlugin() { ModuleProxy.GetInstance().Module = this; UserContent.DeployContent(Constants.PLUGIN_NAME); _applicationManager = ApplicationManager.GetInstance(); /* * Determine status once all plugins have been loaded. */ PluginManager.GetInstance().PluginPostActivate += new MessageHandler(Module_PluginPostActivate); }
// GET: UserContents/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } UserContent userContent = db.UserContents.Find(id); if (userContent == null) { return HttpNotFound(); } ViewBag.ContentId = new SelectList(db.Contents, "ContentId", "Text", userContent.ContentId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", userContent.UserId); return View(userContent); }
public async Task <User> CreateUser(Guid accountId, Guid loginId, Guid contactId) { UserContent content = new UserContent(loginId, accountId, contactId); content.PlatformIdentifier = _platformIdentifier; User newEntity = new User { Contents = content }; var entity = await _context.Users.AddAsync(newEntity); return(entity); }
public void AddNewContent(UserContent content, string ownerId, string profileId, int?groupId) { content.DateCreated = DateTime.Now; content.OwnerId = ownerId; if (groupId.HasValue) { content.GroupId = groupId; } else { content.ProfileId = profileId; } db.Content.Add(content); db.SaveChanges(); }
//public ActionResult Create([Bind(Include = "UserContentId,UserId,ContentId")] UserContent userContent) public ActionResult Create2([Bind(Include = "UserId,ContentId")] UserContent userContent) { //var users = db.Users.Include(u => u.Id).Where(u => u.Email == Email); //return View(userContents.ToList()); if (ModelState.IsValid) { db.UserContents.Add(userContent); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ContentId = new SelectList(db.Contents, "ContentId", "Text", userContent.ContentId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", userContent.UserId); return View(userContent); }
public void UpdateUserContent(string login, RssChannel rssChannel) { using (_db = new ApplicationContext()) { var userId = _db.Users.Where(u => u.Login == login).Select(p => p.Id).First(); var rssCh = _db.RssChanels.FirstOrDefault(rs => rs.Title == rssChannel.Title); UserContent userContent = _db.UserContents.FirstOrDefault(rs => rs.RssChannelId == rssCh.Id && rs.UserId == userId && rs.RssChannel.Link == rssChannel.Link); if (userContent != null) { userContent.RssChannel = rssCh; _db.SaveChanges(); } } }
protected void SendClick(object sender, CommandEventArgs e) { Guid id = new Guid((e.CommandArgument).ToString()); UserContent uContent = new UserContent(); UserInterface user = uContent.GetuserById(id); if (null != user) { string emailcontent = "Hello " + user.UserName + "," + "<br/><br/><b>Username:</b> " + user.UserName + "<br/><br/>Thank you for registering at Alamaat. Your account is created and must be activated before you can use it." + "<br/>To activate the account click on the following link or copy-paste it in your browser:" + "<br/>www.alamaat.biz/activation.aspx?id=" + user.ID + "<br/>After activation you may login to http://www.alamaat.biz/ using the following username and the password you entered during registration:"; SendEmail(user.Email, "Alamaat Account Details for " + user.UserName, emailcontent); } }