public async Task <IActionResult> PutCategoryDetail([FromRoute] long id, [FromBody] MenuCategoryDetail menuCategoryDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != menuCategoryDetail.menuCategoryId)
            {
                return(BadRequest());
            }

            _context.Entry(menuCategoryDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MenuCategoryDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> MenuCategoryDetail(MenuCategoryDetail model)
        {
            var user = await GetCurrentUserAsync();

            if (user != null)
            {
                var role = await _userManager.GetRolesAsync(user);

                TempData["userRole"] = role[0];
                if (ModelState.IsValid)
                {
                    if (model.parentMenuCategoryId == 0)
                    {
                        model.parentMenuCategoryId = -1;
                    }

                    if (model.menuCategoryId != 0)
                    {
                        model.createdDate  = DateTime.Now;
                        model.modifiedDate = DateTime.Now;
                        _context.MenuCategoryDetail.Update(model);
                        _context.SaveChanges();
                    }
                    else
                    {
                        model.createdDate = DateTime.Now;
                        model.sortOrder   = _context.MenuCategoryDetail.Max(a => a.sortOrder) + 1;
                        _context.MenuCategoryDetail.Add(model);
                        _context.SaveChanges();
                    }
                }
                // return RedirectToAction("MenuCategories", "Admin");
                return(Redirect("~/Admin/MenuCategories" + "?resturant=" + model.restaurantId));
            }
            else
            {
                return(RedirectToAction("QuickRegister", "Account"));
            }
        }
Esempio n. 3
0
        public IActionResult AddCategories(MenuCategoryDetail model, string stepTwo, string update, long?id)
        {
            string rid = HttpContext.Request.Form["rid"];

            if (!string.IsNullOrEmpty(stepTwo))
            {
                if (stepTwo.ToLower() == "save and continue")
                {
                    long   Id               = Convert.ToInt32(id);
                    string parentCategory   = HttpContext.Request.Form["CatName"];
                    string NewCategory      = HttpContext.Request.Form["NewCategory"];
                    string menuCategoryDesc = HttpContext.Request.Form["menuCategoryDesc"];

                    if (!string.IsNullOrEmpty(NewCategory))
                    {
                        MenuCategoryDetail _menucats = new MenuCategoryDetail();
                        _menucats.createdDate      = DateTime.Now;
                        _menucats.isEnabled        = true;
                        _menucats.menuCategoryDesc = menuCategoryDesc;
                        _menucats.menuCategoryName = NewCategory;
                        _menucats.modifiedDate     = DateTime.Now;

                        long pcatId = 0;
                        if (!string.IsNullOrEmpty(parentCategory))
                        {
                            if (parentCategory.ToLower() != "no parent")
                            {
                                var pcats = _context.MenuCategoryDetail.FirstOrDefault(a => a.restaurantId == Convert.ToInt32(rid) && a.menuCategoryName.ToLower() == parentCategory.ToLower());
                                _menucats.parentMenuCategoryId = pcats.menuCategoryId;
                                pcatId = pcats.menuCategoryId;
                            }
                        }
                        _menucats.restaurantId = Convert.ToInt32(rid);
                        var _sorder   = _context.MenuCategoryDetail.Where(a => a.restaurantId == Convert.ToInt32(rid) && a.parentMenuCategoryId == pcatId).Max(a => a.sortOrder);
                        int sortOrder = 0;
                        if (_sorder > 0)
                        {
                            _menucats.sortOrder = _sorder + 1;
                        }
                        else
                        {
                            _menucats.sortOrder = _sorder + 1;
                        }

                        _context.MenuCategoryDetail.Add(_menucats);
                        _context.SaveChanges();
                    }
                }
            }
            else if (!string.IsNullOrEmpty(update))
            {
                if (update.ToLower() == "update")
                {
                    string             parentCategory   = HttpContext.Request.Form["CatName"];
                    string             NewCategory      = HttpContext.Request.Form["NewCategory"];
                    string             menuCategoryDesc = HttpContext.Request.Form["menuCategoryDesc"];
                    string             catId            = HttpContext.Request.Form["mcId"];
                    string             ddMenuCategories = HttpContext.Request.Form["pcid"];
                    string             Sorder           = HttpContext.Request.Form["Sorder"];
                    MenuCategoryDetail _menucats        = new MenuCategoryDetail();
                    long pcatId = 0;
                    if (!string.IsNullOrEmpty(parentCategory))
                    {
                        if (parentCategory.ToLower() != "no parent")
                        {
                            var pcats = _context.MenuCategoryDetail.FirstOrDefault(a => a.restaurantId == Convert.ToInt32(rid) && a.menuCategoryName.ToLower() == parentCategory.ToLower());
                            _menucats.parentMenuCategoryId = pcats.menuCategoryId;
                            pcatId = pcats.menuCategoryId;
                        }
                    }
                    _menucats.restaurantId         = Convert.ToInt32(rid);
                    _menucats.menuCategoryDesc     = menuCategoryDesc;
                    _menucats.menuCategoryName     = NewCategory;
                    _menucats.menuCategoryId       = Convert.ToInt32(catId);
                    _menucats.createdDate          = DateTime.Now;
                    _menucats.parentMenuCategoryId = Convert.ToInt32(ddMenuCategories);
                    _menucats.isEnabled            = true;
                    _menucats.modifiedDate         = DateTime.Now;
                    _menucats.sortOrder            = Convert.ToInt32(Sorder);
                    _context.MenuCategoryDetail.Update(_menucats);
                    _context.SaveChanges();
                }
            }
            return(RedirectToAction("SelectMenuItems", "Home", new { id = rid }));
        }
Esempio n. 4
0
        public async Task <IActionResult> QuickAdd(RestaurantDetail model, long?Id)
        {
            string zipCode = HttpContext.Request.Form["ZipCode"];

            if (Id == null)
            {
                //var user = await GetCurrentUserAsync();
                //  model.userId = user.id;
                model.zipCode      = zipCode;
                model.createdDate  = DateTime.Now;
                model.modifiedDate = DateTime.Now;
                _context.RestaurantDetail.Add(model);
                _context.SaveChanges();
                var restId = _context.RestaurantDetail.Max(a => a.id);
                MenuCategoryDetail objmenucats = new MenuCategoryDetail();
                objmenucats.createdDate          = DateTime.Now;
                objmenucats.isEnabled            = true;
                objmenucats.parentMenuCategoryId = null;
                objmenucats.menuCategoryDesc     = null;
                objmenucats.menuCategoryName     = "Breakfast";
                objmenucats.modifiedDate         = DateTime.Now;
                objmenucats.restaurantId         = restId;
                objmenucats.sortOrder            = 1;
                _context.MenuCategoryDetail.Add(objmenucats);
                _context.SaveChanges();

                MenuCategoryDetail objmenucats1 = new MenuCategoryDetail();
                objmenucats1.createdDate         = DateTime.Now;
                objmenucats1.isEnabled           = true;
                objmenucats.parentMenuCategoryId = null;
                objmenucats1.menuCategoryDesc    = null;
                objmenucats1.menuCategoryName    = "Lunch";
                objmenucats1.modifiedDate        = DateTime.Now;
                objmenucats1.restaurantId        = restId;
                objmenucats1.sortOrder           = 2;
                _context.MenuCategoryDetail.Add(objmenucats1);
                _context.SaveChanges();

                MenuCategoryDetail objmenucats2 = new MenuCategoryDetail();
                objmenucats2.createdDate         = DateTime.Now;
                objmenucats2.isEnabled           = true;
                objmenucats2.menuCategoryDesc    = null;
                objmenucats.parentMenuCategoryId = null;
                objmenucats2.menuCategoryName    = "Dinner";
                objmenucats2.modifiedDate        = DateTime.Now;
                objmenucats2.restaurantId        = restId;
                objmenucats2.sortOrder           = 3;
                _context.MenuCategoryDetail.Add(objmenucats2);
                _context.SaveChanges();
                return(RedirectToAction("AddCategories", "Home", new { id = restId }));
            }
            else
            {
                RestaurantDetail objrest      = new RestaurantDetail();
                string           add2         = HttpContext.Request.Form["Address2"];
                string           tagline      = HttpContext.Request.Form["tagline"];
                string           userId       = HttpContext.Request.Form["userId"];
                string           Desc         = HttpContext.Request.Form["Desc"];
                string           country      = HttpContext.Request.Form["country"];
                string           rimage       = HttpContext.Request.Form["rimage"];
                string           Rcategoryids = HttpContext.Request.Form["Rcategoryids"];
                string           isenable     = HttpContext.Request.Form["isenable"];
                string           sortOrder    = HttpContext.Request.Form["sortOrder"];

                objrest.address1 = model.address1;
                if (!string.IsNullOrEmpty(add2))
                {
                    objrest.address2 = add2;
                }
                else
                {
                    objrest.address2 = null;
                }

                if (!string.IsNullOrEmpty(tagline))
                {
                    objrest.tagline = tagline;
                }
                else
                {
                    objrest.tagline = null;
                }

                if (!string.IsNullOrEmpty(userId))
                {
                    objrest.userId = userId;
                }
                else
                {
                    objrest.userId = null;
                }

                if (!string.IsNullOrEmpty(Desc))
                {
                    objrest.Description = Desc;
                }
                else
                {
                    objrest.Description = null;
                }

                if (!string.IsNullOrEmpty(country))
                {
                    objrest.country = country;
                }
                else
                {
                    objrest.country = null;
                }

                if (!string.IsNullOrEmpty(rimage))
                {
                    objrest.mainImageUrl = rimage;
                }
                else
                {
                    objrest.mainImageUrl = null;
                }

                if (!string.IsNullOrEmpty(Rcategoryids))
                {
                    objrest.categoryIds = Rcategoryids;
                }
                else
                {
                    objrest.categoryIds = null;
                }


                objrest.isEnable = true;


                if (!string.IsNullOrEmpty(sortOrder))
                {
                    objrest.sortOrder = Convert.ToInt32(sortOrder);
                }



                objrest.zipCode        = zipCode;
                objrest.city           = model.city;
                objrest.state          = model.state;
                objrest.intro          = model.intro;
                objrest.restaurantName = model.restaurantName;
                objrest.createdDate    = DateTime.Now;
                objrest.modifiedDate   = DateTime.Now;
                objrest.id             = Convert.ToInt32(Id);
                _context.Update(objrest);
                _context.SaveChanges();

                return(RedirectToAction("AddCategories", "Home", new { id = Id }));
            }
        }
Esempio n. 5
0
        //Post : Admin/RestaurantDetails/
        public async Task <IActionResult> RestaurantDetails(RestaurantDetail model)
        {
            string ddBrakTimeFrom = HttpContext.Request.Form["ddBrakTimeFrom"];
            string ddBrakTimeTo   = HttpContext.Request.Form["ddBreakTimingTO"];

            var user = await GetCurrentUserAsync();

            if (user != null)
            {
                var role = await _userManager.GetRolesAsync(user);

                TempData["userRole"] = role[0];
                string aa       = HttpContext.Request.Form["cats"];
                string filename = HttpContext.Request.Form["file"];

                string filepath = HttpContext.Request.Form["filePath"];

                if (!string.IsNullOrEmpty(filepath))
                {
                    CloudinaryDotNet.Account account = new CloudinaryDotNet.Account("hkm2gz727", "654416183426452", "AZJIv_WvBo1Z7gkzN-uXFVg2_BE");
                    Cloudinary cloudinary            = new Cloudinary(account);

                    CloudinaryDotNet.Actions.ImageUploadParams uploadParams = new CloudinaryDotNet.Actions.ImageUploadParams();
                    uploadParams.File = new CloudinaryDotNet.Actions.FileDescription(filepath);

                    CloudinaryDotNet.Actions.ImageUploadResult uploadResult = await cloudinary.UploadAsync(uploadParams);

                    string url = cloudinary.Api.UrlImgUp.BuildUrl(String.Format("{0}.{1}", uploadResult.PublicId, uploadResult.Format));
                    model.mainImageUrl = url;
                }
                else
                {
                    string imageurl = HttpContext.Request.Form["imageurl"];
                    model.mainImageUrl = imageurl;
                }
                model.timing1 = model.timing1;
                model.timing2 = model.timing2;

                if (model.id != 0)
                {
                    model.userId       = model.userId;
                    model.categoryIds  = aa;
                    model.modifiedDate = DateTime.Now;
                    _context.RestaurantDetail.Update(model);
                    _context.SaveChanges();
                }
                else
                {
                    model.userId       = user.Id;
                    model.categoryIds  = aa;
                    model.createdDate  = DateTime.Now;
                    model.modifiedDate = DateTime.Now;
                    model.sortOrder    = _context.RestaurantDetail.Max(a => a.sortOrder) + 1;
                    _context.RestaurantDetail.Add(model);
                    _context.SaveChanges();
                }
                var restId = _context.RestaurantDetail.Max(a => a.id);
                MenuCategoryDetail objmenucats = new MenuCategoryDetail();
                objmenucats.createdDate          = DateTime.Now;
                objmenucats.isEnabled            = true;
                objmenucats.parentMenuCategoryId = null;
                objmenucats.menuCategoryDesc     = null;
                objmenucats.menuCategoryName     = "Breakfast";
                objmenucats.modifiedDate         = DateTime.Now;
                objmenucats.restaurantId         = restId;
                objmenucats.sortOrder            = 1;
                _context.MenuCategoryDetail.Add(objmenucats);
                _context.SaveChanges();

                MenuCategoryDetail objmenucats1 = new MenuCategoryDetail();
                objmenucats1.createdDate         = DateTime.Now;
                objmenucats1.isEnabled           = true;
                objmenucats.parentMenuCategoryId = null;
                objmenucats1.menuCategoryDesc    = null;
                objmenucats1.menuCategoryName    = "Lunch";
                objmenucats1.modifiedDate        = DateTime.Now;
                objmenucats1.restaurantId        = restId;
                objmenucats1.sortOrder           = 2;
                _context.MenuCategoryDetail.Add(objmenucats1);
                _context.SaveChanges();

                MenuCategoryDetail objmenucats2 = new MenuCategoryDetail();
                objmenucats2.createdDate         = DateTime.Now;
                objmenucats2.isEnabled           = true;
                objmenucats2.menuCategoryDesc    = null;
                objmenucats.parentMenuCategoryId = null;
                objmenucats2.menuCategoryName    = "Dinner";
                objmenucats2.modifiedDate        = DateTime.Now;
                objmenucats2.restaurantId        = restId;
                objmenucats2.sortOrder           = 3;
                _context.MenuCategoryDetail.Add(objmenucats2);
                _context.SaveChanges();
                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                return(RedirectToAction("QuickRegister", "Account"));
            }
        }