Exemple #1
0
 public void SetToDoItems(List<ToDoItem> items)
 {
     var array = items.ToArray();
     var heloer = new Helper { Items = items.ToArray() };
     string r = JsonConvert.SerializeObject(heloer);
     _fileManager.SaveText(file, r);
 }
Exemple #2
0
        public ActionResult Create(List list, int[] selectedCategories)
        {
            if (list == null)
                return HttpNotFound();

            ApplicationUserManager userManager = HttpContext.GetOwinContext()
                                            .GetUserManager<ApplicationUserManager>();
            ApplicationUser user = userManager.FindByEmail(User.Identity.Name);
            list.UserId = user.Id;
            if (selectedCategories != null)
            {
                foreach (var cat in db.Categories.Where(c => selectedCategories.Contains(c.Id)))
                {
                    list.Categories.Add(cat);
                }
            }

            if (!ModelState.IsValid)
                return HttpNotFound();

            db.Lists.Add(list);
            db.SaveChanges();

            return RedirectToAction("Lists");
        }
 public ActionResult Index()
 {
     IList<Todo> todos = _repository.GetTodos();
     List<ListTodoVM> todoVMs = new List<ListTodoVM>();
     foreach (var todo in todos)
     {
         ListTodoVM vm = new ListTodoVM{Entry = todo.Item, Title = todo.Title, Id = todo.Id};
         todoVMs.Add(vm);
     }
     return View(todoVMs);
 }
        public ActionResult Index()
        {
            List<ToDoListViewModel> model = new List<ToDoListViewModel>();
            var entities = _repository.GetTodos();

            foreach (var entity in entities)
            {
                ToDoListViewModel m = new ToDoListViewModel {Title = entity.Title, Entry = entity.Item};
                model.Add(m);
            }

            return View(model);
        }
        public void Add(Todo todo)
        {
            if (todo.Id == 0)
            {
                if (_fakeDbContext.Count == 0)
                    todo.Id = 1;

                else
                    todo.Id = _fakeDbContext.Max(item => item.Id) + 1;
            }

            _fakeDbContext.Add(todo);
            _fakeDbContext = _fakeDbContext.OrderBy(item => item.Id).ToList();
        }
Exemple #6
0
        public ActionResult Edit(List<Item> item, int listId)
        {
            if (item == null)
                return HttpNotFound("not have eny item");

            for (int i = 0; i < item.Count; i++)
            {
                //item[i].
                if (item[i].Text == null && item[i].Id != 0)
                {
                    Item dellItemItem = db.Items.Find(item[i].Id);

                    db.Items.Remove(dellItemItem);
                    db.SaveChanges();
                }
                else if (item[i].Id != 0)
                {
                    Item editItem = db.Items.Find(item[i].Id);
                    if (editItem != null)
                    {
                        editItem.Text = item[i].Text;
                        db.Entry(editItem).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                        return HttpNotFound("text lenght min 3 , max 50");

                }
                else if (item[i].Id == 0)
                {
                    item[i].ListId = listId;
                    if (ModelState.IsValid)
                    {
                        db.Items.Add(item[i]);
                        db.SaveChanges();
                    }
                    else
                    {
                        return HttpNotFound("text lenght min 3 , max 50");
                    }

                }
            }

            return Redirect("/List/DetailList/" + listId);
        }
Exemple #7
0
		public async Task<ManageInfoViewModel> GetManageInfo(string returnUrl, bool generateState = false)
		{
			IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

			if (user == null)
			{
				return null;
			}

			List<UserLoginInfoViewModel> logins = new List<UserLoginInfoViewModel>();

			foreach (IdentityUserLogin linkedAccount in user.Logins)
			{
				logins.Add(new UserLoginInfoViewModel
				{
					LoginProvider = linkedAccount.LoginProvider,
					ProviderKey = linkedAccount.ProviderKey
				});
			}

			if (user.PasswordHash != null)
			{
				logins.Add(new UserLoginInfoViewModel
				{
					LoginProvider = LocalLoginProvider,
					ProviderKey = user.UserName,
				});
			}

			return new ManageInfoViewModel
			{
				LocalLoginProvider = LocalLoginProvider,
				Email = user.UserName,
				Logins = logins,
				ExternalLoginProviders = GetExternalLogins(returnUrl, generateState)
			};
		}
Exemple #8
0
			public IList<Claim> GetClaims()
			{
				IList<Claim> claims = new List<Claim>();
				claims.Add(new Claim(ClaimTypes.NameIdentifier, ProviderKey, null, LoginProvider));

				if (UserName != null)
				{
					claims.Add(new Claim(ClaimTypes.Name, UserName, null, LoginProvider));
				}

				return claims;
			}
Exemple #9
0
		public IEnumerable<ExternalLoginViewModel> GetExternalLogins(string returnUrl, bool generateState = false)
		{
			IEnumerable<AuthenticationDescription> descriptions = Authentication.GetExternalAuthenticationTypes();
			List<ExternalLoginViewModel> logins = new List<ExternalLoginViewModel>();

			string state;

			if (generateState)
			{
				const int strengthInBits = 256;
				state = RandomOAuthStateGenerator.Generate(strengthInBits);
			}
			else
			{
				state = null;
			}

			foreach (AuthenticationDescription description in descriptions)
			{
				ExternalLoginViewModel login = new ExternalLoginViewModel
				{
					Name = description.Caption,
					Url = Url.Route("ExternalLogin", new
					{
						provider = description.AuthenticationType,
						response_type = "token",
						client_id = Startup.PublicClientId,
						redirect_uri = new Uri(Request.RequestUri, returnUrl).AbsoluteUri,
						state = state
					}),
					State = state
				};
				logins.Add(login);
			}

			return logins;
		}
Exemple #10
0
        public ActionResult RemoveExternalLogins()
        {
            ICollection<OAuthAccount> accounts = OAuthWebSecurity.GetAccountsFromUserName(User.Identity.Name);
            List<ExternalLogin> externalLogins = new List<ExternalLogin>();
            foreach (OAuthAccount account in accounts)
            {
                AuthenticationClientData clientData = OAuthWebSecurity.GetOAuthClientData(account.Provider);

                externalLogins.Add(new ExternalLogin
                {
                    Provider = account.Provider,
                    ProviderDisplayName = clientData.DisplayName,
                    ProviderUserId = account.ProviderUserId,
                });
            }

            ViewBag.ShowRemoveButton = externalLogins.Count > 1 || OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name));
            return PartialView("_RemoveExternalLoginsPartial", externalLogins);
        }
Exemple #11
0
 public List()
 {
     Categories = new List<Category>();
     Items=new List<Item>();
 }
Exemple #12
0
        public ActionResult DetailList(int? id)
        {
            string currentUserId = CurrentUserId();
            if (id == null)
                return HttpNotFound();

            List list = new List();
            list = db.Lists.FirstOrDefault(l => l.Id == id && l.UserId == currentUserId);
            if (list == null)
                return HttpNotFound();

            return View(list);
        }
Exemple #13
0
        public ActionResult Edit(List list, int[] selectedCategories)
        {
            List newList = new List();
            newList = db.Lists.Find(list.Id);
            newList.Text = list.Text;
            newList.Categories.Clear();
            if (selectedCategories != null)
            {
                foreach (var cat in db.Categories.Where(c => selectedCategories.Contains(c.Id)))
                {
                    newList.Categories.Add(cat);
                }
            }

            db.Entry(newList).State = EntityState.Modified;
            db.SaveChanges();
            return Redirect("/list/detailList/" + newList.Id);
        }
Exemple #14
0
        public ActionResult Edit(int? id)
        {
            string currentUserId = CurrentUserId();
            if (id == null)
                return HttpNotFound();
            List list = new List();
            list = db.Lists.FirstOrDefault(l => l.Id == id && l.UserId == currentUserId);
            if (list == null)
                return HttpNotFound();

            IEnumerable<Category> categories = db.Categories.Where(c => c.UserId == currentUserId); ;
            ViewBag.Categories = categories;
            return View(list);
        }
Exemple #15
0
 public Category()
 {
     Lists = new List<List>();
 }