Exemplo n.º 1
0
 internal void Edit(CHEF chef)
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         chefRepo.Update(chef);
         chefRepo.Save();
     }
 }
Exemplo n.º 2
0
 internal void Add(CHEF chef)
 {
     using (entity = new klassycafeEntities())
     {
         chefRepo = new GenericRepo <CHEF>(entity);
         chefRepo.Insert(chef);
         chefRepo.Save();
     }
 }
Exemplo n.º 3
0
        public ActionResult Chef_Remove(int ID)
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("Login"));
            }

            CHEF c = chefDA.GetById(ID);

            return(View(c));
        }
Exemplo n.º 4
0
        public ActionResult Chef_Edit(int ID)
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("Login"));
            }

            CHEF chef = chefDA.GetById(ID);

            PopulateStateDropdownList(chef.STATE_ID);
            return(View(chef));
        }
Exemplo n.º 5
0
 public ActionResult RemoveChefForm(CHEF chef)
 {
     try
     {
         chefDA.Remove(chef.ID);
         return(RedirectToAction("Chefs", "Admin"));
     }
     catch (Exception ex)
     {
         ViewBag.Error = "Try Again.";
         PopulateStateDropdownList(chef.STATE_ID);
         return(View("Chef_Remove", chef));
     }
 }
Exemplo n.º 6
0
        internal CHEFLIST GetByIdForList(int id)
        {
            using (entity = new klassycafeEntities())
            {
                chefRepo  = new GenericRepo <CHEF>(entity);
                stateRepo = new GenericRepo <STATE>(entity);

                CHEF chef = chefRepo.FindByID(id);

                return(new CHEFLIST()
                {
                    chef = chef,
                    stateName = stateRepo.FindByID(chef.STATE_ID).NAME
                });
            }
        }
Exemplo n.º 7
0
        public ActionResult EditChefForm(CHEF chef)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    CHEF c = chefDA.GetById(chef.ID);
                    if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
                    {
                        if (System.IO.File.Exists(Server.MapPath("~/Content/images/chef/" + chef.PICTURE)))
                        {
                            System.IO.File.Delete(Server.MapPath("~/Content/images/chef/" + chef.PICTURE));
                        }

                        string dosyaAdi   = Guid.NewGuid().ToString().Replace("-", "");
                        string uzanti     = Path.GetExtension(Request.Files[0].FileName);
                        string tamYolYeri = "~/Content/images/chef/" + dosyaAdi + uzanti;
                        Request.Files[0].SaveAs(Server.MapPath(tamYolYeri));
                        chef.PICTURE = dosyaAdi + uzanti;
                    }
                    else
                    {
                        chef.PICTURE = c.PICTURE;
                    }

                    chefDA.Edit(chef);
                    return(RedirectToAction("Chefs", "Admin"));
                }
                else
                {
                    ViewBag.Error = "Try Again.";
                    PopulateStateDropdownList(chef.STATE_ID);
                    return(View("Chef_Edit", chef));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Try Again.";
                PopulateStateDropdownList(chef.STATE_ID);
                return(View("Chef_Edit", chef));
            }
        }
Exemplo n.º 8
0
        public ActionResult AddChefForm(CHEF chef)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (Request.Files.Count > 0)
                    {
                        string dosyaAdi   = Guid.NewGuid().ToString().Replace("-", "");
                        string uzanti     = Path.GetExtension(Request.Files[0].FileName);
                        string tamYolYeri = "~/Content/images/chef/" + dosyaAdi + uzanti;
                        Request.Files[0].SaveAs(Server.MapPath(tamYolYeri));
                        chef.PICTURE = dosyaAdi + uzanti;
                    }
                    else
                    {
                        ViewBag.Error = "Add Image.";
                        PopulateStateDropdownList();
                        return(View("Chef_Add", chef));
                    }

                    chefDA.Add(chef);
                    return(RedirectToAction("Chefs", "Admin"));
                }
                else
                {
                    ViewBag.Error = "Try Again.";
                    PopulateStateDropdownList(chef.STATE_ID);
                    return(View("Chef_Add", chef));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Try Again.";
                PopulateStateDropdownList(chef.STATE_ID);
                return(View("Chef_Add", chef));
            }
        }