コード例 #1
0
        public ActionResult LoadArticle(ContentModelLoad model)
        {
            ContentModel modelo = new ContentModel();
            List<CategoryModel> cateList = new List<CategoryModel>();
            foreach (var item in model.CategoriesId)
            {
                cateList.Add(catRepository.Get(item));
            }
            modelo.Comments = new List<CommentModel>();
            modelo.Categories = cateList;
            modelo.Content = model.Content;
            modelo.DatePosted = DateTime.Now;
            modelo.IsActive = model.IsActive;
            modelo.IsFeatured = model.IsFeatured;
            modelo.IsImportant = model.IsImportant;
            modelo.Resume = model.Resume;
            modelo.Title = model.Title;
            UserModel us = userRepository.GetByMail(model.UserMail);
            if (us == null)
            {
                us = new UserModel();
                us.FirstDateOn = DateTime.Now;
                us.LastDateOn = DateTime.Now;
                us.UserMail = model.UserMail;
                us.UserName = model.UserName;
                // userRepository.Save(us);
            }
            modelo.User = us;
            repository.SaveContent(modelo);

            return View ("LoadImages", modelo.Id);
        }
コード例 #2
0
 public ActionResult Subscribe(string Email)
 {
     UserModel us = repository.GetByMail(Email);
     if (us != null)
     {
         Session["registered"] = true;
         return RedirectToAction(TempData["Action"].ToString(), TempData["Controler"].ToString(), TempData["Param"].ToString());
     }
     us = new UserModel();
     us.FirstDateOn = DateTime.Now;
     us.LastDateOn = DateTime.Now;
     us.UserMail = Email;
     us.UserName = Email;
     if (Email.ToLower().Contains("hotmail"))
     {
         us.Type = UserType.Hotmail.ToString();
     }
     else if (Email.ToLower().Contains("yahoo"))
     {
         us.Type = UserType.Yahoo.ToString();
     }
     else
     {
         us.Type = UserType.Gmail.ToString();
     }
     repository.Save(us);
     Session["registered"] = true;
     return RedirectToAction(TempData["Action"].ToString(), TempData["Controler"].ToString(), TempData["Param"].ToString());
 }
コード例 #3
0
        public ActionResult PostToContent(string ContentId, string texto, string user, string email)
        {
            int iparentContent = Convert.ToInt32(ContentId);
            try
            {
                UserModel us = userRepository.GetByMail(email);
                if (us == null)
                {
                    us = new UserModel();
                    us.FirstDateOn = DateTime.Now;
                    us.LastDateOn = DateTime.Now;
                    us.UserMail = email;
                    us.UserName = user;
                    // userRepository.Save(us);
                    Session["registered"] = true;
                }
                CommentModel comment = new CommentModel();
                comment.Comment = texto;
                comment.ContentWherePosted = repository.Get(iparentContent);
                if (comment.ContentWherePosted == null)
                {
                    throw new Exception("Error: por favor intente nuevamente");
                }
                comment.PostingUser = us;
                comment.IsFatherNode = true;
                comment.IsActive = true;
                comment.DatePosted = DateTime.Now;
                repository.SaveComment(comment);

                return PartialView("SingleComment", comment);
            }
            catch (Exception e)
            {
                return new EmptyResult() ;

            }
        }
コード例 #4
0
ファイル: UserRepository.cs プロジェクト: fedemalt91/fedemalt
 public void Save(UserModel user)
 {
     dbContext.Users.Add(user);
     dbContext.SaveChanges();
 }