示例#1
0
        public ActionResult Signup(UserViewModel uv)
        {
            tbluser tbl = db.tblusers.Where(u => u.Username == uv.Username).FirstOrDefault();

            if (tbl != null)
            {
                return(Json(new { success = false, message = "User Already Register" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                tbluser tb = new tbluser();
                tb.Username = uv.Username;
                tb.Password = uv.Password;
                tb.FullName = uv.FullName;
                tb.Email    = uv.Email;
                db.tblusers.Add(tb);
                db.SaveChanges();

                tblUserRole ud = new tblUserRole();
                ud.UserId = tb.UserId;
                ud.RoleId = 2;
                db.tblUserRoles.Add(ud);
                db.SaveChanges();
                return(Json(new { success = true, message = "User Register Successfully" }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public ActionResult AddOrEdit(UserViewModel uv)
        {
            tbluser tb = new tbluser();

            tb.Username = uv.Username;
            tb.Email    = uv.Email;
            tb.Password = uv.Password;

            HttpPostedFileBase fup = Request.Files["Photo"];

            if (fup != null)
            {
                if (fup.FileName != "")
                {
                    tb.Photo = fup.FileName;
                    fup.SaveAs(Server.MapPath("~/images/" + fup.FileName));
                }
            }
            _db.tblusers.Add(tb);
            _db.SaveChanges();

            tblUserRole ud = new tblUserRole();

            ud.UserId     = tb.UserId;
            ud.UserRoleId = 1;
            _db.tblUserRoles.Add(ud);
            _db.SaveChanges();
            ViewBag.Message = "User Created Successfully";


            return(View());
        }
        public ActionResult AddOrEdit(ProductViewModel ivm)
        {
            using (KantipurDBEntities db = new KantipurDBEntities())
            {
                if (ivm.ProductId == 0)
                {
                    tblProduct itm = new tblProduct();

                    itm.CategoryId   = Convert.ToInt32(ivm.CategoryId);
                    itm.ProductName  = ivm.ProductName;
                    itm.UnitPrice    = ivm.UnitPrice;
                    itm.SellingPrice = ivm.SellingPrice;
                    itm.Description  = ivm.Description;
                    itm.IsSpecial    = ivm.IsSpecial;
                    HttpPostedFileBase fup = Request.Files["Photo"];

                    if (fup != null)
                    {
                        if (fup.FileName != "")
                        {
                            fup.SaveAs(Server.MapPath("~/ProductImages/" + fup.FileName));
                            itm.Photo = fup.FileName;
                        }
                    }



                    db.tblProducts.Add(itm);
                    db.SaveChanges();
                    ViewBag.Message = "Created Successfully";
                }
                else
                {
                    tblProduct itm = db.tblProducts.Where(i => i.ProductId == ivm.ProductId).FirstOrDefault();
                    itm.CategoryId   = Convert.ToInt32(ivm.CategoryId);
                    itm.ProductName  = ivm.ProductName;
                    itm.UnitPrice    = ivm.UnitPrice;
                    itm.SellingPrice = ivm.SellingPrice;
                    itm.Description  = ivm.Description;
                    itm.IsSpecial    = ivm.IsSpecial;
                    HttpPostedFileBase fup = Request.Files["Photo"];
                    if (fup != null)
                    {
                        if (fup.FileName != "")
                        {
                            fup.SaveAs(Server.MapPath("~/ProductImages/" + fup.FileName));
                            itm.Photo = fup.FileName;
                        }
                    }



                    db.SaveChanges();
                    ViewBag.Message = "Updated Successfully";
                }
                ViewBag.Categories = db.tblCategories.ToList();
                return(View(new ProductViewModel()));
            }
        }
 public ActionResult AddOrEdit(tblCategory sm)
 {
     using (KantipurDBEntities db = new KantipurDBEntities())
     {
         if (sm.CategoryId == 0)
         {
             db.tblCategories.Add(sm);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(sm).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
示例#5
0
 public ActionResult Delete(int id)
 {
     using (KantipurDBEntities db = new KantipurDBEntities())
     {
         tblCategory sm = db.tblCategories.Where(x => x.CategoryId == id).FirstOrDefault();
         db.tblCategories.Remove(sm);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
示例#6
0
 public ActionResult AddOrEdit(CategoryViewModel sm)
 {
     using (KantipurDBEntities db = new KantipurDBEntities())
     {
         if (sm.CategoryId == 0)
         {
             tblCategory tb = new tblCategory();
             tb.CategoryName = sm.CategoryName;
             db.tblCategories.Add(tb);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             tblCategory tbm = db.tblCategories.Where(m => m.CategoryId == sm.CategoryId).FirstOrDefault();
             tbm.CategoryName = sm.CategoryName;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
        public ActionResult ViewOrder_Post(int id)
        {
            using (KantipurDBEntities db = new KantipurDBEntities())
            {
                tblOrder sm = db.tblOrders.Where(x => x.OrderId == id).FirstOrDefault();
                sm.DeliveredStatus = "Confirmed";



                db.SaveChanges();
                return(RedirectToAction("ManageOrder", "Order"));
            }
        }
        public ActionResult ChangePassword(ChangePasswordViewModel ch)
        {
            string username = Session["Username"].ToString();

            tbluser us = db.tblusers.Where(u => u.Username == username && u.Password == ch.OldPassword).FirstOrDefault();

            if (us != null)
            {
                us.Password = ch.NewPassword;
                db.SaveChanges();
            }
            else
            {
                return(Json(new { success = false, message = "You Enter Wrong Password" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = true, message = "Password Changed Successfully" }, JsonRequestBehavior.AllowGet));
        }