Beispiel #1
0
 public ActionResult Edit(ShopView editShop)
 {
     if (ModelState.IsValid)
     {
         var editDbShop = db.Shops.FirstOrDefault(f => f.Id == editShop.Id);
         if (editDbShop == null)
         {
             return(HttpNotFound());
         }
         else
         {
             if (editShop.ShopImage != null && editShop.ShopImage.ContentLength > 0)
             {
                 editDbShop.SaveImageFile(editShop.ShopImage, "/Image/Shops");
             }
             editShop.ViewFromDb(editDbShop);
             editDbShop.IsActive = Convert.ToBoolean(editShop.Activ);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         return(HttpNotFound());
     }
 }
Beispiel #2
0
        public ActionResult Index(UserSignUp SignUp)
        {
            if (ModelState.IsValid && SignUp.Condition == "true")
            {
                var userdb = db.Users.FirstOrDefault(f => f.UserName.ToUpper() == SignUp.UserName.ToUpper() || f.Mail == SignUp.Mail);
                if (userdb == null && SignUp.Password == SignUp.ConfirmPassword)
                {
                    UserDb user = new UserDb();

                    SignUp.ViewFromDb(user);

                    user.HashPassword = SHA.CustumSHA(SignUp.Password);
                    db.Users.Add(user);
                    db.SaveChanges();
                    var userCod = user.Id + 10000;
                    user.UserCod = user.Id.ToString() + userCod.ToString();
                    db.UserRoles.Add(new UserRole()
                    {
                        UserDbId = user.Id, RoleId = 1
                    });
                    db.SaveChanges();
                    return(RedirectToAction("Login", "UserLogin"));
                }
                else
                {
                    ViewBag.faq = db.Faqs.FirstOrDefault(f => f.FaqTitle == "Sifaris Sertleri");
                    return(View(SignUp));
                }
            }
            ViewBag.faq = db.Faqs.FirstOrDefault(f => f.FaqTitle == "Sifaris Sertleri");
            return(View(SignUp));
        }
Beispiel #3
0
 public ActionResult Edit(Country EditCountry)
 {
     if (ModelState.IsValid)
     {
         var editDbCountry = db.Countries.FirstOrDefault(f => f.Id == EditCountry.Id);
         if (editDbCountry == null)
         {
             return(HttpNotFound());
         }
         else
         {
             if (EditCountry.CountryFlag != null && EditCountry.CountryFlag.ContentLength > 0)
             {
                 editDbCountry.SaveImageFile(EditCountry.CountryFlag, "/Image/Country");
             }
             editDbCountry.IsActive    = Convert.ToBoolean(EditCountry.Activ);
             editDbCountry.CauntryName = EditCountry.CauntryName;
             editDbCountry.CurrencyId  = EditCountry.CurrencyId;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         return(HttpNotFound());
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Menyu menyu = db.Menyus.Find(id);

            db.Menyus.Remove(menyu);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "Id,StatusName")] OrderStatus orderStatus)
        {
            if (ModelState.IsValid)
            {
                db.OrderStatuses.Add(orderStatus);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(orderStatus);
        }
        public ActionResult Create([Bind(Include = "Id,ContentText,Activ")] AboutDb aboutDb)
        {
            if (ModelState.IsValid)
            {
                aboutDb.IsActive   = Convert.ToBoolean(aboutDb.Activ);
                aboutDb.CreateDate = DateTime.Now;
                db.Abouts.Add(aboutDb);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aboutDb));
        }
Beispiel #7
0
 public ActionResult DeletePost(int id)
 {
     try
     {
         var deletCurrency = db.Currencies.FirstOrDefault(f => f.Id == id);
         db.Currencies.Remove(deletCurrency);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(HttpNotFound());
     }
 }
 public ActionResult Create(Tarif create)
 {
     if (ModelState.IsValid)
     {
         create.IsActive = Convert.ToBoolean(create.Activ);
         db.Tarifs.Add(create);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Beispiel #9
0
        public async Task <ActionResult> Edit(NewsDbModel EditNews)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var EditNewsDb = await db.News.FirstOrDefaultAsync(f => f.Id == EditNews.Id);

                    if (EditNewsDb == null)
                    {
                        return(HttpNotFound());
                    }
                    else
                    {
                        EditNews.IsActive = Convert.ToBoolean(EditNews.Activ);//????
                        if (EditNews.NewsRefreshDate == null)
                        {
                            EditNews.NewsRefreshDate = DateTime.Now;
                        }
                        if (EditNews.NewsImg != null && EditNews.NewsImg.ContentLength > 0)
                        {
                            EditNews.SaveImageFile(EditNews.NewsImg, "/Image/News");
                            ViewModelChangeDbModel <NewsDbModel, NewsDbModel> nw = new ViewModelChangeDbModel <NewsDbModel, NewsDbModel>();
                            nw.ViewFromDb(EditNews, EditNewsDb, "NewsCreateDate");
                            await db.SaveChangesAsync();

                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ViewModelChangeDbModel <NewsDbModel, NewsDbModel> nw = new ViewModelChangeDbModel <NewsDbModel, NewsDbModel>();
                            nw.ViewFromDb(EditNews, EditNewsDb, "NewsCreateDate");
                            db.SaveChanges();
                            return(RedirectToAction("Index"));
                        }
                    }
                }
                return(HttpNotFound());
            }
            catch
            {
                return(HttpNotFound());
            }
        }
Beispiel #10
0
 public ActionResult Edit(Setting edit)
 {
     if (ModelState.IsValid)
     {
         if (edit.TitleImage != null && edit.TitleImage.ContentLength > 0)
         {
             var imgName   = ProsesImageFile.FileName(edit.TitleImage);
             var ImagePath = ProsesImageFile.ImagePath(imgName, "/Image/Settings");
             edit.TitleImage.SaveAs(ImagePath);
             edit.TitleImagePath = "/Image/Settings/" + imgName;
         }
         db.Entry(edit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult Create(CaruselView NewCarusel)
        {
            if (ModelState.IsValid)
            {
                CaruselDb newDbCarusel = new CaruselDb();

                var imgName = ProsesImageFile.FileName(NewCarusel.File);
                var imgPath = ProsesImageFile.ImagePath(imgName, "/Image/Carusel");
                NewCarusel.File.SaveAs(imgPath);

                newDbCarusel.Text      = NewCarusel.Text;
                newDbCarusel.Title     = NewCarusel.Title;
                newDbCarusel.IsActive  = false;
                newDbCarusel.ImagePath = "/Image/Carusel/" + imgName;
                db.Carusels.Add(newDbCarusel);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult EditUser(AdminEditUser user)
        {
            if (ModelState.IsValid)
            {
                string id;
                string IsActiv;
                if (user.UserRoles != null && user.UserRoles.Length > 0)
                {
                    foreach (var i in user.UserRoles)
                    {
                        id      = i.Substring(i.IndexOf("-") + 1);
                        IsActiv = i.Substring(0, i.Length - id.Length - 1);

                        if (IsActiv == "Activ")
                        {
                            var item = db.UserRoles.FirstOrDefault(f => f.UserDbId == user.Id && f.RoleId.ToString() == id);
                            if (item == null)
                            {
                                db.UserRoles.Add(new UserRole()
                                {
                                    UserDbId = user.Id, RoleId = int.Parse(id)
                                });
                            }
                        }
                        else
                        {
                            var item = db.UserRoles.FirstOrDefault(f => f.Id.ToString() == id);
                            if (item != null)
                            {
                                db.UserRoles.Remove(item);
                            }
                        }
                    }
                }
            }
            db.SaveChanges();
            return(RedirectToAction("UsersIndex"));
        }
Beispiel #13
0
        public async Task <ActionResult> ForgetPassword(ForgetThePassword forgetPsw)
        {
            if (ModelState.IsValid)
            {
                var user = await db.Users.FirstOrDefaultAsync(s => s.Mail == forgetPsw.Mail && s.FirstName == forgetPsw.FirstName && s.LastName == forgetPsw.LastName);

                if (user == null)
                {
                    return(View());
                }
                else
                {
                    string newPsw  = GenerateNewCod.NewPassword();
                    var    newHash = SHA.CustumSHA(newPsw);
                    user.HashPassword = newHash;
                    string mesg = newPsw + "-bu sizin yeni parolunuzdur.Hesabinizin Tehlukesizliyi ucun tez bir zamanda deyisdirin";
                    SendEmail.SendNewMail(user.Mail, mesg, "Parol deyisikliyi");
                    db.SaveChanges();
                    return(RedirectToAction("Login"));
                }
            }
            return(View());
        }
Beispiel #14
0
 public ActionResult IsActiv(ChangeActivStatus[] id)
 {
     if (id == null)
     {
         return(Json(new { success = true, responseText = "Hec Bir Deyisiklik Olmadi!" }));
     }
     else
     {
         foreach (var i in id)
         {
             var ActivFaq = db.Faqs.FirstOrDefault(f => f.Id == i.id);
             if (ActivFaq == null)
             {
                 return(HttpNotFound());
             }
             else
             {
                 ActivFaq.IsActive = ChangeIsActivFromIndex.ChangeStatus(i.status);
             }
         }
         db.SaveChanges();
         return(Json(new { success = true, responseText = "Emeliyyat Ugurlu Oldu !" }));
     }
 }