Exemplo n.º 1
0
        public ActionResult Create(ReminderModel model)
        {
            User user = userRepositoty.LoadByLogin(User.Identity.Name);

            reminderRepository.Save(new Reminder()
            {
                Title         = model.Title,
                Description   = model.Description,
                IsDone        = false,
                TimeToAchieve = model.TimeToAchieve,
                User          = user
            });

            return(RedirectToAction("List"));
        }
Exemplo n.º 2
0
        public ActionResult Create(NoteModel model)
        {
            User user = userRepositoty.LoadByLogin(User.Identity.Name);

            DB.File file = null;
            if (model.BinaryFile != null)
            {
                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(model.BinaryFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(model.BinaryFile.ContentLength);
                }
                file = new DB.File()
                {
                    BinaryFile = fileData,
                    FileType   = model.BinaryFile.ContentType
                };
            }

            noteRepository.Save(new Note()
            {
                Title        = model.Title,
                Published    = model.Published,
                Text         = model.Text,
                Tags         = GetTags(model.Tags),
                CreationDate = DateTime.Now,
                User         = user,
                File         = file
            });

            return(RedirectToAction("Notes"));
        }
Exemplo n.º 3
0
        public ActionResult Login(LoginModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Что-то пошло не так!");
                return(View(model));
            }

            var user = UserRepository.LoadByLogin(model.Login);

            if (user == null || user.Password != model.Password)
            {
                ModelState.AddModelError("", "Неверный логин или пароль");
                return(View(model));
            }

            FormsAuthentication.SetAuthCookie(user.Login, false);

            return(RedirectToAction("Index", "Note"));
        }