public static bool Create(adminUser obj)
 {
     bool check = true;
     try
     {
         var context = new Ecommerce.DbEntity.ecommerceEntities();
         context.users.Add(new DbEntity.user
         {
             Address1 = obj.Address1,
             Address2 = obj.Address2,
             City = obj.City,
             ContactNumber = obj.ContactNumber,
             Country = obj.Country,
             DAddress1 = obj.DAddress1,
             DAddress2 = obj.DAddress2,
             DCity = obj.DCity,
             DCountry = obj.DCountry,
             DName = obj.DName,
             DPostCode = obj.DPostCode,
             DState = obj.DState,
             Email = obj.Email,
             Name = obj.Name,
             Password = obj.Password,
             PostCode = obj.PostCode,
             State = obj.State,
             Isadmin = obj.Isadmin
         });
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         check = false;
     }
     return check;
 }
 public ActionResult Save(adminUser obj)
 {
     bool check = true;
     if (Request.IsAuthenticated)
     {
         if (obj.id > 0)
         {
             check = AdminUserDal.Update(obj);
         }
         else
         {
             check = AdminUserDal.Create(obj);
         }
         if (check)
         {
             TempData["message"] = "Saved successfully";
         }
         else
         {
             TempData["message"] = "Error while saving data";
         }
         return RedirectToAction("Create", "User");
     }
     else
     {
         return RedirectToAction("index", "home");
     }
 }
 public ActionResult Create()
 {
     if (Request.IsAuthenticated)
     {
         ViewBag.PageTittle = "Add User";
         ViewBag.breadCrum = "<a href='/Admin/Category/index'>Category</a> >> Add Category";
         adminUser obj = new adminUser();
         return View(obj);
     }
     else
     {
         return RedirectToAction("index", "home");
     }
 }
 public ActionResult Edit(int id)
 {
     if (Request.IsAuthenticated)
     {
         ViewBag.PageTittle = "Edit User";
         ViewBag.breadCrum = "<a href='/Admin/Category/index'>Category</a> >> Edit Category";
         adminUser obj = new adminUser();
         obj = AdminUserDal.GetById(id);
         return View("Create", obj);
     }
     else
     {
         return RedirectToAction("index", "home");
     }
 }
        public static adminUser ValidateUser(LoginModel loginobj)
        {
            adminUser User = null;
            var context = new Ecommerce.DbEntity.ecommerceEntities();
            var obj = context.users.Where(m => m.Email == loginobj.Email && m.Password == loginobj.Password && m.Isadmin == loginobj.isadmin).FirstOrDefault();
            if (obj != null)
            {
                User = new adminUser();
                User.Address1 = obj.Address1;
                User.Address2 = obj.Address2;
                User.City = obj.City;
                User.ContactNumber = obj.ContactNumber;
                User.Country = obj.Country;
                User.DAddress1 = obj.DAddress1;
                User.DAddress2 = obj.DAddress2;
                User.DCity = obj.DCity;
                User.DCountry = obj.DCountry;
                User.DName = obj.DName;
                User.DPostCode = obj.DPostCode;
                User.DState = obj.DState;
                User.Email = obj.Email;
                User.Name = obj.Name;
                User.Password = obj.Password;
                User.PostCode = obj.PostCode;
                User.State = obj.State;

            }
            return User;
        }
 public static bool Update(adminUser obj)
 {
     bool check = true;
     try
     {
         var context = new Ecommerce.DbEntity.ecommerceEntities();
         var User = context.users.Where(m => m.id == obj.id).FirstOrDefault();
         User.Address1 = obj.Address1;
         User.Address2 = obj.Address2;
         User.City = obj.City;
         User.ContactNumber = obj.ContactNumber;
         User.Country = obj.Country;
         User.DAddress1 = obj.DAddress1;
         User.DAddress2 = obj.DAddress2;
         User.DCity = obj.DCity;
         User.DCountry = obj.DCountry;
         User.DName = obj.DName;
         User.DPostCode = obj.DPostCode;
         User.DState = obj.DState;
         User.Email = obj.Email;
         User.Name = obj.Name;
         User.Password = obj.Password;
         User.PostCode = obj.PostCode;
         User.State = obj.State;
         User.Isadmin = obj.Isadmin;
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         check = false;
     }
     return check;
 }
 public static adminUser GetById(int id)
 {
     var context = new Ecommerce.DbEntity.ecommerceEntities();
     var obj = context.users.Where(m => m.id == id).FirstOrDefault();
     var User = new adminUser();
     User.Address1 = obj.Address1;
     User.Address2 = obj.Address2;
     User.City = obj.City;
     User.ContactNumber = obj.ContactNumber;
     User.Country = obj.Country;
     User.DAddress1 = obj.DAddress1;
     User.DAddress2 = obj.DAddress2;
     User.DCity = obj.DCity;
     User.DCountry = obj.DCountry;
     User.DName = obj.DName;
     User.DPostCode = obj.DPostCode;
     User.DState = obj.DState;
     User.Email = obj.Email;
     User.Name = obj.Name;
     User.Password = obj.Password;
     User.PostCode = obj.PostCode;
     User.State = obj.State;
     User.Isadmin = Convert.ToBoolean(obj.Isadmin);
     return User;
 }