示例#1
0
        public IActionResult DeleteAddress(string name, string address)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin"))
            {
                return(RedirectToAction("Error", "Admin"));
            }
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Company", new { name = name }));
            }
            if (name == "" || name == null || address == "" || address == null)
            {
                return(RedirectToAction("Index"));
            }
            Debug.WriteLine("Kill" + address);
            context.RemoveAddressFromClientList(name, address);
            context.LogAction("Client", "Address (" + address + ") has been removed from client " + name + ".", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))));
            return(RedirectToAction("Company", new { name = name }));
        }