Ejemplo n.º 1
0
        public async Task <ActionResult> Create([Bind(Include = "id,name,zipcode,description,isActive")] city city)
        {
            if (ModelState.IsValid)
            {
                city.created_at = DateTime.Now;
                city.updated_at = DateTime.Now;
                db.citys.Add(city);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(city));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Delete(int id)
        {
            try
            {
                // TODO: Add delete logic here
                List <spa_images> spaImg = db.spa_images.Where(x => x.spa_id == id).ToList();
                foreach (var item in spaImg)
                {
                    try
                    {
                        if (System.IO.File.Exists(item.image_url))
                        {
                            System.IO.File.Delete(item.image_url);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                db.spa_images.RemoveRange(spaImg);
                db.spa_time.RemoveRange(db.spa_time.Where(x => x.spa_id == id));
                db.spa_prices.RemoveRange(db.spa_prices.Where(x => x.spa_id == id));
                db.spa_basic_info.RemoveRange(db.spa_basic_info.Where(x => x.id == id));
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Create([Bind(Include = "id,parentId,name,subheading,description,isActive")] CategeogySubCategory categeogySubCategory, string Cat_SubCat)
        {
            if (ModelState.IsValid)
            {
                categeogySubCategory.created_at = DateTime.Now;
                categeogySubCategory.updated_at = DateTime.Now;
                db.CategeogySubCategories.Add(categeogySubCategory);
                await db.SaveChangesAsync();

                if (String.IsNullOrEmpty(Cat_SubCat))
                {
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("SubCategory"));
            }
            if (String.IsNullOrEmpty(Cat_SubCat))
            {
                return(View(categeogySubCategory));
            }
            return(View("Create_SubCat", categeogySubCategory));
        }