コード例 #1
0
        public async Task <ActionResult> GetMenuById(int id)
        {
            //string strint = id.Trim().ToString();
            //var intid = Convert.ToInt32(strint);
            MenuMasterModel pro = new MenuMasterModel();

            MenuMasterModelSignleRootObject obj = new MenuMasterModelSignleRootObject();

            string url = GetUrl(2);

            url = url + "MenuMaster/GetMenuById?id=" + Convert.ToInt32(id) + "";
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage responseMessage = await client.GetAsync(url);

                if (responseMessage.IsSuccessStatusCode)
                {
                    var response = responseMessage.Content.ReadAsStringAsync().Result;
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Ignore,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };
                    obj = JsonConvert.DeserializeObject <MenuMasterModelSignleRootObject>(response, settings);
                    pro = obj.data;
                    TempData["item"] = pro;
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public HttpResponseMessage AddNewMenu(string menuid, string menuname, decimal menuprice, string storeid)
        {
            MenuMasterModel model = new MenuMasterModel();

            model.MenuId    = Convert.ToInt32(menuid);
            model.MenuName  = menuname;
            model.MenuPrice = menuprice;
            model.StoreId   = Convert.ToInt32(storeid);
            ResponseStatus response = new ResponseStatus();

            try
            {
                var data = _repository.AddNewMenu(model);
                //if (data.MenuId > 0)
                //{
                //    response.isSuccess = true;
                //    response.serverResponseTime = DateTime.Now;
                return(Request.CreateResponse(HttpStatusCode.OK, new { data }));
                //}
                //else
                //{
                //    response.isSuccess = false;
                //    response.serverResponseTime = DateTime.Now;
                //    return Request.CreateResponse(HttpStatusCode.BadRequest, new { data });
                //}
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Worng !", ex));
            }
        }
コード例 #3
0
ファイル: Menues.cs プロジェクト: yupplemukesh/DoorserveApp
        public async Task <ResponseModel> AddUpdateMenu(MenuMasterModel menu, char action)
        {
            List <SqlParameter> sp    = new List <SqlParameter>();
            SqlParameter        param = new SqlParameter("@MenuId", ToDBNull(menu.MenuCapId));

            sp.Add(param);
            param = new SqlParameter("@Menu_name", ToDBNull(menu.Menu_Name));
            sp.Add(param);
            param = new SqlParameter("@CapName", ToDBNull(menu.CapName));
            sp.Add(param);
            param = new SqlParameter("@IconFileName", ToDBNull(menu.IconFileName));
            sp.Add(param);
            param = new SqlParameter("@PerentMenuId", ToDBNull(menu.ParentMenuId));
            sp.Add(param);
            param = new SqlParameter("@order", ToDBNull(menu.shortOrder));
            sp.Add(param);
            param = new SqlParameter("@IsActive", ToDBNull(menu.IsActive));
            sp.Add(param);
            param = new SqlParameter("@user", ToDBNull(menu.CreatedBy));
            sp.Add(param);
            param = new SqlParameter("@action", ToDBNull(action));
            sp.Add(param);
            param = new SqlParameter("@ServiceTypeIds", ToDBNull(menu.ServiceTypeIds));
            sp.Add(param);
            var sql = "Add_Modify_Menu @MenuId,@Menu_name,@CapName,@IconFileName,@PerentMenuId,@order,@IsActive,@user,@action,@ServiceTypeIds";
            var res = await _context.Database.SqlQuery <ResponseModel>(sql, sp.ToArray()).FirstOrDefaultAsync();

            if (res.ResponseCode == 0)
            {
                res.IsSuccess = true;
            }
            return(res);
        }
コード例 #4
0
        public async Task <ActionResult> AddNewMenu(FormCollection fc, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                MenuMasterModel model     = new MenuMasterModel();
                string          menuname  = fc["MenuName"];
                string          menuprice = fc["MenuPrice"];
                string          url       = GetUrl(2);
                url = url + "MenuMaster/AddNewMenu?menuname=" + menuname + "&menuprice=" + menuprice + "";

                using (HttpClient client = new HttpClient())
                {
                    HttpResponseMessage responseMessage = await client.GetAsync(url);

                    MenuMasterModelRootObject result = new MenuMasterModelRootObject();
                    if (responseMessage.IsSuccessStatusCode)
                    {
                        var response = responseMessage.Content.ReadAsStringAsync().Result;
                        var settings = new JsonSerializerSettings
                        {
                            NullValueHandling     = NullValueHandling.Ignore,
                            MissingMemberHandling = MissingMemberHandling.Ignore
                        };
                        result = JsonConvert.DeserializeObject <MenuMasterModelRootObject>(response);
                        int menuid = result.Data.MenuId;
                        if (menuid > 0)
                        {
                            var allowedExtensions = new[]
                            {
                                ".Jpg", ".png", ".jpg", "jpeg", ".JPG",
                            };
                            //string imagepath = "http://103.233.79.234/Data/EverGreen_Android/LocalityPictures/";
                            model.ImageUrl = file.ToString();                               //getting complete url
                            var fileName = Path.GetFileName(file.FileName);                 //getting only file name(ex-ganesh.jpg)
                            var ext      = Path.GetExtension(file.FileName);                //getting the extension(ex-.jpg)
                            if (allowedExtensions.Contains(ext))                            //check what type of extension
                            {
                                string name   = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                                string myfile = +menuid + ext;                              //appending the name with id
                                                                                            // store the file inside ~/project folder(Img)
                                                                                            //var path = Path.Combine(imagepath, myfile);
                                string path = @"C:\inetpub\wwwroot\Data\EverGreen_Android\\MenuPictures\" + Server.HtmlEncode(myfile);
                                model.ImageUrl = path;
                                file.SaveAs(path);
                            }
                        }
                        else
                        {
                            ViewBag.message = "Please choose only Image file";
                        }
                    }
                    return(View("Index"));
                }
            }
            else
            {
                return(View("Index"));
            }
        }
コード例 #5
0
        public ActionResult DynamicLinks()
        {
            MenuMasterModel objMenuMaster;

            if (CurrentUser != null)
            {
                objMenuMaster = CurrentUser.Menues;
            }
            else
            {
                objMenuMaster = new MenuMasterModel();
            }
            return(PartialView("_SideMenu", objMenuMaster));
        }
コード例 #6
0
        public async Task <ActionResult> CreateOrEdit(MenuMasterModel menu)
        {
            if (menu.IconFileName != null && menu.IconFileNamePath != null)
            {
                if (System.IO.File.Exists(Server.MapPath(path) + menu.IconFileName))
                {
                    System.IO.File.Delete(Server.MapPath(path) + menu.IconFileName);
                }
            }
            if (menu.IconFileNamePath != null)
            {
                menu.IconFileName = SaveImageFile(menu.IconFileNamePath);
            }
            string services = "";

            foreach (var item in menu.ServiceTypeList)
            {
                if (item.IsChecked)
                {
                    services = services + "," + item.Value;
                }
            }
            menu.ServiceTypeIds = services.Trim(',');
            ResponseModel res = null;

            if (menu.MenuCapId == 0)
            {
                res = await _menues.AddUpdateMenu(menu, 'I');
            }
            else
            {
                res = await _menues.AddUpdateMenu(menu, 'U');
            }
            TempData["response"] = res;
            var menuesModel = new MenuesModel();

            menuesModel.Menues = await _menues.GetMenues();

            menuesModel.menu = new MenuMasterModel {
                ServiceTypeList = await CommonModel.GetServiceType(new Filters.FilterModel())
            };
            return(RedirectToAction("index", menuesModel));
        }
コード例 #7
0
        // GET: MenuMaster
        public async Task <ActionResult> Index()
        {
            ViewBag.LoginID     = Session["LoginID"].ToString();
            ViewBag.Username    = Session["Username"].ToString();
            ViewBag.StoreStatus = Session["StoreStatus"].ToString();
            ViewBag.Message     = "Your application Daily Activity page.";
            //return View();
            string preurl = GetUrl(2);

            preurl = preurl + "Store/GetAllStoreList";
            StoreMasterModelRootObject pobj = new StoreMasterModelRootObject();

            //List<ProductMasterModel> Prlist = new List<ProductMasterModel>();
            using (HttpClient prclient = new HttpClient())
            {
                HttpResponseMessage responseMessage = await prclient.GetAsync(preurl);

                if (responseMessage.IsSuccessStatusCode)
                {
                    var result = responseMessage.Content.ReadAsStringAsync().Result;
                    pobj = JsonConvert.DeserializeObject <StoreMasterModelRootObject>(result);
                    IList <SelectListItem> ProSelectList = new List <SelectListItem>();
                    foreach (var item in pobj.data)
                    {
                        ProSelectList.Add(new SelectListItem {
                            Text = item.StoreName, Value = item.StoreId.ToString()
                        });
                    }
                    ProSelectList.Insert(0, new SelectListItem()
                    {
                        Value = "", Text = "Select Store"
                    });
                    //ProSelectList.Insert(1, new SelectListItem() { Value = "0", Text = "All" });
                    ViewBag.StoreList = ProSelectList;
                }
            }
            MenuMasterModel menu = (MenuMasterModel)TempData["item"];

            return(View(menu));
        }
        public async Task <ActionResult <ApiResponse <MenuMasterModel> > > CreateMenuMaster(MenuMasterModel form)
        {
            try
            {
                if (string.IsNullOrEmpty(form.Menu_Name))
                {
                    return(new ApiResponse <MenuMasterModel> {
                        code = 0, message = "Invalid Details"
                    });
                }
                form.Menu_Name = form.Menu_Name.TrimStart().TrimEnd().ToUpper();
                var lang = await _context.Menu_Masters.Where(x => x.Menu_Name == form.Menu_Name).FirstOrDefaultAsync();

                if (lang == null)
                {
                    lang = new Menu_Master
                    {
                        Menu_Name = form.Menu_Name,
                    };
                    _context.Add(lang);
                    await _context.SaveChangesAsync();

                    var query = _context.Language_Masters.Select(s => new MenuMasterModel
                    {
                        Menu_Name = form.Menu_Name
                    }).FirstOrDefault();

                    return(new ApiResponse <MenuMasterModel> {
                        code = 1, message = "Success", data = query
                    });
                }

                else
                {
                    return(new ApiResponse <MenuMasterModel> {
                        code = 0, message = "Already Exists"
                    });
                }
            }

            catch (Exception)
            {
                return(new ApiResponse <MenuMasterModel> {
                    code = 0, message = "Failed"
                });
            }
        }
コード例 #9
0
        public async Task <ActionResult> Login(LoginViewModel m)
        {
            if (string.IsNullOrEmpty(m.Email) || string.IsNullOrEmpty(m.Password))
            {
                ViewBag.Message = "Please provide email and password";
                return(View(m));
            }
            var encrpt_Pass = doorserve.Encrypt_Decript_Code.encrypt_decrypt.Encrypt(m.Password, true);

            using (var con = new SqlConnection(_connectionString))
            {
                await con.OpenAsync();

                string iconPath = "/uploadedImages/icon-img/";
                var    result   = await con.QueryMultipleAsync("Login_Proc", new { Username = m.Email, Password = encrpt_Pass },
                                                               commandType : CommandType.StoredProcedure);

                var rs = await result.ReadSingleOrDefaultAsync <dynamic>();

                if (rs != null)
                {
                    var PerentMenues = await result.ReadAsync <MenuMasterModel>() as List <MenuMasterModel>;

                    PerentMenues = PerentMenues.Select(x => new MenuMasterModel {
                        MenuCapId = x.MenuCapId, IsActive = x.IsActive, Menu_Name = x.Menu_Name, CapName = x.CapName, PagePath = x.PagePath, IconFileNameUl = iconPath + x.IconFileName, ParentMenuId = x.ParentMenuId, ParentMenuName = x.ParentMenuName
                    }).ToList();
                    var SubMenues = await result.ReadAsync <MenuMasterModel>() as List <MenuMasterModel>;

                    SubMenues = SubMenues.OrderBy(x => x.ParentMenuId).OrderBy(x => x.shortOrder).ToList();
                    var manues = new MenuMasterModel {
                        ParentMenuList = PerentMenues, SubMenuList = SubMenues
                    };

                    SessionModel session = new SessionModel
                    {
                        UserId             = rs.UserId,
                        Email              = rs.Email,
                        RefKey             = rs.RefKey,
                        CompanyId          = rs.CompanyId,
                        UserTypeName       = rs.UserTypeName,
                        UserRole           = rs.RoleName,
                        UserName           = rs.UserName,
                        Mobile             = rs.Mobile,
                        ContactCareEmail   = rs.ContactCareEmail,
                        CustomerCareNumber = rs.CustomerCareNumber,
                        RoleId             = rs.RoleId,
                        UserTypeId         = rs.UserTypeId,
                        Menues             = manues
                    };

                    if (!session.UserTypeName.ToLower().Contains("super admin"))
                    {
                        session.LogoUrl = "/uploadedImages/Companies/Logo/" + rs.CompLogo;
                    }


                    Session["User"] = session;
                    var claims = new List <Claim>();
                    claims.Add(new Claim(ClaimTypes.Name, m.Email));
                    claims.Add(new Claim(ClaimTypes.NameIdentifier, m.Email));
                    claims.Add(new Claim(ClaimTypes.Email, rs.Email));
                    var id  = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
                    var ctx = Request.GetOwinContext();
                    var authenticationManager = ctx.Authentication;
                    authenticationManager.SignIn(id);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ViewBag.Message = "User Name or Password is not correct";
                }
            }
            return(View());
        }
コード例 #10
0
        public async Task <ActionResult> AddNewMenu(FormCollection fc, HttpPostedFileBase file)
        {
            //ViewBag.StoreId = Session["StoreId"].ToString();
            if (ModelState.IsValid)
            {
                int MenuId = 0;
                //string storeid = "";
                MenuMasterModel model     = new MenuMasterModel();
                string          menuid    = fc["MenuId"];
                string          menuname  = fc["MenuName"];
                string          menuprice = fc["MenuPrice"];
                //string storeid= fc["StoreName"];
                //if (ViewBag.StoreId == "0")
                //{
                //    storeid = fc["StoreName"];
                //}
                //else
                //{
                //    storeid = ViewBag.StoreId;
                //}

                string url = GetUrl(2);
                url = url + "Menu/AddNewMenu?menuid=" + menuid + "&menuname=" + menuname + "&menuprice=" + menuprice + "";

                using (HttpClient client = new HttpClient())
                {
                    HttpResponseMessage responseMessage = await client.GetAsync(url);

                    MenuMasterModelSignleRootObject result = new MenuMasterModelSignleRootObject();
                    if (responseMessage.IsSuccessStatusCode)
                    {
                        var response = responseMessage.Content.ReadAsStringAsync().Result;
                        var settings = new JsonSerializerSettings
                        {
                            NullValueHandling     = NullValueHandling.Ignore,
                            MissingMemberHandling = MissingMemberHandling.Ignore
                        };
                        result = JsonConvert.DeserializeObject <MenuMasterModelSignleRootObject>(response);
                        if (result.data.MenuId == 0)
                        {
                            MenuId = Convert.ToInt32(menuid);
                        }
                        else
                        {
                            MenuId = result.data.MenuId;
                        }
                        if (MenuId > 0)
                        {
                            try
                            {
                                var allowedExtensions = new[]
                                {
                                    ".Jpg", ".png", ".jpg", "jpeg", ".JPG",
                                };
                                //string imagepath = "http://103.233.79.234/Data/ShamSweets_Android/LocalityPictures/";
                                model.ImageUrl = file.ToString();                               //getting complete url
                                var fileName = Path.GetFileName(file.FileName);                 //getting only file name(ex-ganesh.jpg)
                                var ext      = Path.GetExtension(file.FileName);                //getting the extension(ex-.jpg)
                                if (allowedExtensions.Contains(ext))                            //check what type of extension
                                {
                                    string name   = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                                    string myfile = +MenuId + ext;                              //appending the name with id
                                                                                                // store the file inside ~/project folder(Img)
                                                                                                //var path = Path.Combine(imagepath, myfile);
                                    string path = @"C:\inetpub\wwwroot\Data\StoreFeedback_Android\MenuPictures\" + Server.HtmlEncode(myfile);
                                    model.ImageUrl = path;
                                    //file.SaveAs(path);
                                    var fInfo = new FileInfo(myfile);
                                    if (!fInfo.Exists)
                                    {
                                        file.SaveAs(path);
                                    }
                                    else
                                    {
                                        System.IO.File.Copy(path, path, true);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        else
                        {
                            TempData["message"] = "Please choose only Image file!";
                        }
                        TempData["message"] = "New Menu Added Successfully!";
                    }
                    else
                    {
                        TempData["message"] = "New Menu Not Added Successfully!";
                    }
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["message"] = "New Menu Not Added Successfully!";
                return(RedirectToAction("Index"));
            }
        }