public ActionResult Edit([Bind(Include = "UserId,AuthorityId,UserName,Password,Email,Name,Images")] Users users, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                var edited = db.Users.Find(users.UserId);

                if (file != null)
                {
                    ImageUpload.DeleteByPath(edited.Images);
                    ImageUpload imageUpload = new ImageUpload();
                    edited.Images = imageUpload.ImageResizeUser(file, 240, 240);
                }

                edited.Authority   = users.Authority;
                edited.AuthorityId = users.AuthorityId;
                edited.Comments    = users.Comments;
                edited.Email       = users.Email;
                edited.Name        = users.Name;
                edited.Password    = users.Password;
                edited.UserId      = users.UserId;
                edited.UserName    = users.UserName;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AuthorityId = new SelectList(db.Authority, "AuthorityId", "Authority1", users.AuthorityId);
            return(View(users));
        }
        public ActionResult DeleteConfirmed(short id)
        {
            Article article = db.Article.Find(id);

            if (article == null)
            {
                return(HttpNotFound());
            }

            foreach (var item in article.Comments.ToList())
            {
                db.Comments.Remove(item);
            }



            var degis = db.Article.Find(id);

            article.Labels.Clear();

            ImageUpload.DeleteByPath(article.ImageUrl);
            ImageUpload.DeleteByPath(article.ImageUrlt);


            //if (ImageUpload.DeleteByPath(article.ImageUrl))
            //{
            //    Debug.Write("Sildi");
            //}
            //if (ImageUpload.DeleteByPath(article.ImageUrlt))
            //{
            //    Debug.Write("Sildi");
            //}
            //else
            //{
            //    Debug.Write("olmadı");
            //}
            //var silinecek_makale = db.Article.Where(w => w.ArticleId == article.ArticleId).FirstOrDefault();
            //db.Article.Remove(silinecek_makale);
            //article.ImageUrl.Remove(article.ArticleId);
            //article.ImageUrlt.Remove(article.ArticleId);
            //db.Article.Remove(silinecek_makale);
            db.Article.Remove(article);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "ArticleId,CategoryId,Baslik,ImageUrl,ImageUrlt,Description,Date,Reads,Labels,UserId")] Article article, FormCollection form, string editor1, string etiket, IEnumerable <HttpPostedFileBase> files, HttpPostedFileBase file0, HttpPostedFileBase file1)
        {
            if (ModelState.IsValid)
            {
                string sightlist = form["sightlist"];

                ImageUpload imageUpload = new ImageUpload();


                var degis = db.Article.Find(article.ArticleId);

                if (files.ElementAt(1) != null && files.ElementAt(0) != null)
                {
                    ImageUpload.DeleteByPath(degis.ImageUrl);
                    ImageUpload.DeleteByPath(degis.ImageUrlt);

                    file0           = files.ElementAt(0);
                    file1           = files.ElementAt(1);
                    degis.ImageUrl  = imageUpload.ImageResizeFirst(file0, 240, 240);
                    degis.ImageUrlt = imageUpload.ImageResizeSecond(file1, 100, 200);;
                }
                else if (files.ElementAt(0) != null)
                {
                    ImageUpload.DeleteByPath(degis.ImageUrl);

                    file0             = files.ElementAt(0);
                    degis.ImageUrl    = imageUpload.ImageResizeFirst(file0, 240, 240);
                    article.ImageUrlt = degis.ImageUrlt;
                    article.ImageUrl  = degis.ImageUrl;
                }
                else if (files.ElementAt(1) != null)
                {
                    ImageUpload.DeleteByPath(degis.ImageUrlt);
                    file1             = files.ElementAt(1);
                    degis.ImageUrlt   = imageUpload.ImageResizeSecond(file1, 240, 240);
                    article.ImageUrl  = degis.ImageUrl;
                    article.ImageUrlt = degis.ImageUrlt;
                }
                else
                {
                    article.ImageUrlt = degis.ImageUrlt;
                    article.ImageUrl  = degis.ImageUrl;
                }

                var karma = "";

                if (etiket == "" && sightlist == null)
                {
                    degis.Labels.Clear();
                }

                else if (sightlist != null && sightlist != "")
                {
                    string[] etiketdizi = sightlist.Split(',');

                    foreach (var item in etiketdizi)
                    {
                        var gecen = db.Labels.Find((Convert.ToInt32(item)));
                        if (item == "")
                        {
                            continue;
                        }
                        else
                        {
                            karma = karma + gecen.LabelName + ",";
                        }
                    }
                    karma = karma + etiket;
                }


                if (karma != null && karma != "")
                {
                    string[] etiketdizi = karma.Split(',');

                    foreach (var item in etiketdizi)
                    {
                        if (item == "")
                        {
                            continue;
                        }

                        if (db.Labels.Any(p => p.LabelName.Equals(item)))
                        {
                            var gecen = db.Labels.Where(p => p.LabelName.Equals(item)).First().LabelId;
                            degis.Labels.Add(db.Labels.Find(gecen));
                        }

                        else
                        {
                            var yenietikets = new Labels {
                                LabelName = item
                            };
                            if (yenietikets.ToString().Length <= 50)
                            {
                                article.Labels.Add(yenietikets);
                            }
                        }
                    }
                }

                else
                {
                    degis.Labels.Clear();
                    string[] etiketdizi = etiket.Split(',');

                    foreach (var item in etiketdizi)
                    {
                        if (item == "")
                        {
                            continue;
                        }
                        else if (db.Labels.Any(p => p.LabelName.Equals(item)))
                        {
                            var gecen = db.Labels.Where(p => p.LabelName.Equals(item)).First().LabelId;

                            degis.Labels.Add(db.Labels.Find(gecen));
                        }

                        else
                        {
                            var yenietikets = new Labels {
                                LabelName = item
                            };
                            if (yenietikets.ToString().Length <= 50)
                            {
                                article.Labels.Add(yenietikets);
                            }
                        }
                    }
                    karma = karma + etiket;
                }


                degis.Baslik      = article.Baslik;
                degis.Reads       = article.Reads;      //
                degis.Description = editor1;            //
                degis.Comments    = article.Comments;   //
                degis.CategoryId  = article.CategoryId; //
                degis.Date        = DateTime.Now;       //
                degis.UserId      = article.UserId;

                ViewBag.etiket = etiket;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryId = new SelectList(db.Category, "CategoryId", "CategoryName", article.CategoryId);

            return(View(article));
        }