Beispiel #1
0
        public string Send(string thought, int top, int left, int level)
        {
            AnaWeenEntities entities = new AnaWeenEntities();
            var user = entities.Members.First(u => u.Login == User.Identity.Name || u.Mail == User.Identity.Name);
            if (user != null)
            {
                var lexs = thought.Split(' ').Where(l => l.Length > 0 && l[0] == '#');
                var newThought = new Thought() { Text = thought, Top = top, left = left, Level = level };
                foreach (var lex in lexs)
                {
                    if (!entities.Lexicons.Any(l => l.Value == lex))
                    {
                        newThought.Lexicon.Add(new Lexicon() { Value = lex });
                    }
                    else
                    {
                        newThought.Lexicon.Add(entities.Lexicons.FirstOrDefault(l => l.Value == lex));
                    }
                }
                user.Thoughts.Add(newThought);
                entities.SaveChanges();
                return thought;
            }
            else
            {
                return "Error";
            }

        }
Beispiel #2
0
 public string UpdatePosition(int id, int top, int left)
 {
     AnaWeenEntities entities = new AnaWeenEntities();
     var fekra = entities.Thoughts.FirstOrDefault(f => f.Id == id);
     fekra.Top = top;
     fekra.left = left;
     entities.SaveChanges();
     return "lux";
 }
Beispiel #3
0
 public void UpdateFekra(int id,string thought )
 {
     AnaWeenEntities entities = new AnaWeenEntities();
     var user = entities.Members.First(u => u.Login == User.Identity.Name || u.Mail == User.Identity.Name);
     if (user != null)
     {
         var fekra = user.Thoughts.FirstOrDefault(t => t.Id == id);
         fekra.Text = thought;
         entities.SaveChanges();               
     }
 
 }
Beispiel #4
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                AnaWeenEntities entities = new AnaWeenEntities();
                entities.Members.AddObject(new Member() { Login = model.UserName, Password = model.Password, Mail = model.Email });
                try
                {
                    entities.SaveChanges();
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home", new { login = model.UserName });
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Beispiel #5
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    AnaWeenEntities entities = new AnaWeenEntities();
                    var user = entities.Members.FirstOrDefault(u => u.Login == User.Identity.Name);
                    //MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    if (user != null)
                    {
                        user.Password = model.NewPassword;
                        entities.SaveChanges();
                        return RedirectToAction("ChangePasswordSuccess");
                    }
                    // changePasswordSucceeded = user.Password (model.OldPassword, model.NewPassword);
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Beispiel #6
0
 public string UpdateVisibility(int id, bool visibility)
 {
     AnaWeenEntities entities = new AnaWeenEntities();
     var fekra = entities.Thoughts.FirstOrDefault(f => f.Id == id);
     fekra.Visibility = visibility;
     entities.SaveChanges();
     return "lux";
 }
Beispiel #7
0
 public string UpdateLevel(int id, int level)
 {
     AnaWeenEntities entities = new AnaWeenEntities();
     var fekra = entities.Thoughts.FirstOrDefault(f => f.Id == id);
     fekra.Level = level;
     entities.SaveChanges();
     return "lux";
 }