示例#1
0
 public ActionResult AddOrEdit(Employee emp)
 {
     try
     {
         if (emp.ImageUpload != null)
         {
             string fileName  = Path.GetFileNameWithoutExtension(emp.ImageUpload.FileName);
             string extension = Path.GetExtension(emp.ImageUpload.FileName);
             fileName      = fileName + DateTime.Now.ToString("yymmssfff") + extension;
             emp.ImagePath = "~/AppFiles/Images/" + fileName;
             emp.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName));
         }
         using (MvcProjectAliEntities db = new MvcProjectAliEntities())
         {
             if (emp.EmployeeID == 0)
             {
                 db.Employees.Add(emp);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(emp).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Create(Guide guide)
 {
     if (ModelState.IsValid)
     {
         db.Guides.Add(guide);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(guide));
 }
示例#3
0
        public ActionResult Create(Tourist tourist)
        {
            if (ModelState.IsValid)
            {
                db.Tourists.Add(tourist);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tourist));
        }
示例#4
0
        public ActionResult Create(Hotel hoteldetail)
        {
            if (ModelState.IsValid)
            {
                db.Hotels.Add(hoteldetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TouristId = new SelectList(db.Tourists, "TouristId", "TouristName", hoteldetail.TouristId); //for dropdown
            return(View(hoteldetail));
        }
        public ActionResult Create(ChefVB chefVB)
        {
            if (ModelState.IsValid)
            {
                var chef = Mapper.Map <Chef>(chefVB);
                db.Chefs.Add(chef);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(chefVB));
        }
示例#6
0
 public ActionResult Delete(int id)
 {
     try
     {
         using (MvcProjectAliEntities db = new MvcProjectAliEntities())
         {
             Employee emp = db.Employees.Where(x => x.EmployeeID == id).FirstOrDefault <Employee>();
             db.Employees.Remove(emp);
             db.SaveChanges();
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
示例#7
0
 public JsonResult Add(Reporter user)
 {
     _context.Reporters.Add(user);
     _context.SaveChanges();
     return(Json(JsonRequestBehavior.AllowGet));
 }