예제 #1
0
        public ActionResult Create(tblEmployeeDetail employeeDetail, HttpPostedFileBase FileUpload)
        {
            using (BusManagementContext db = new BusManagementContext())
            {
                try
                {
                    //Save image in folder

                    string FileName     = Path.GetFileName(FileUpload.FileName);
                    string SaveLocation = Server.MapPath("~/EmployeePicture/" + FileName);
                    FileUpload.SaveAs(SaveLocation);

                    //save image name in database

                    employeeDetail.employeeImage = "~/EmployeePicture/" + FileName;


                    // byte image Save


                    employeeDetail.employeePicture = new byte[FileUpload.ContentLength];
                    ViewBag.TeacherPicture         = FileUpload.InputStream.Read(employeeDetail.employeePicture, 0, FileUpload.ContentLength);

                    db.tblEmployeeDetails.Add(employeeDetail);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
        }
        public ActionResult Create(VmDepartmentDesignation vm)
        {
            if (ModelState.IsValid)
            {
                tblDepartment d = new tblDepartment();
                d.Department = vm.Department;
                db.tblDepartments.Add(d);
                db.SaveChanges();

                tblDesignation dg = new tblDesignation();
                dg.Designation  = vm.Designation;
                dg.DepartmentID = d.Id;
                db.tblDesignations.Add(dg);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View());
        }
 public ActionResult Delete(VmDepartmentDesignation vm)
 {
     using (BusManagementContext db = new BusManagementContext())
     {
         var DepartmentDelete  = db.tblDepartments.First(d => d.Id == vm.Id);
         var DesignationDelete = db.tblDesignations.First(dg => dg.DepartmentID == vm.Id);
         db.tblDepartments.Remove(DepartmentDelete);
         db.tblDesignations.Remove(DesignationDelete);
         db.SaveChanges();
         return(View(vm));
     }
 }
 // GET: VmDepartmentDesignations/Delete/5
 public ActionResult Delete(int id)
 {
     using (BusManagementContext db = new BusManagementContext())
     {
         var DepartmentDelete  = db.tblDepartments.First(d => d.Id == id);
         var DesignationDelete = db.tblDesignations.First(dg => dg.DepartmentID == id);
         db.tblDepartments.Remove(DepartmentDelete);
         db.tblDesignations.Remove(DesignationDelete);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
예제 #5
0
 public ActionResult Delete(int id)
 {
     using (BusManagementContext db = new BusManagementContext())
     {
         try
         {
             tblEmployeeDetail emp = db.tblEmployeeDetails.Find(id);
             db.tblEmployeeDetails.Remove(emp);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch
         {
             return(View());
         }
     }
 }