Exemplo n.º 1
0
 public void Modify <T>(T entity) where T : class
 {
     try
     {
         db.Entry <T>(entity).State = System.Data.EntityState.Modified;
     }
     catch (DbEntityValidationException exception)
     {
         this.DisplayValidationErrors(exception);
     }
 }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "CodeID,CodeDescription,CodeValue")] HourCode hourCode)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hourCode).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hourCode));
 }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "JobRoleID,JobDescription")] Job_Role job_Role)
 {
     if (ModelState.IsValid)
     {
         db.Entry(job_Role).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(job_Role));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "id_WorkAssignment,id_Customer,Title,Description,Deadline,InProsess,InProgressAt,Completed,CompletedAt,CreatedAt,LastModifiedAt,DeletedAt,Active")] WorkAssignment workAssignment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(workAssignment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_Customer = new SelectList(db.Customers, "id_Customer", "CustomerName", workAssignment.id_Customer);
     return(View(workAssignment));
 }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "id_Employee,id_contractor,FirstName,LastName,PhoneNumber,EmailAdress,CreatedAt,LastModifiedAt,DeletedAt,Active")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_contractor = new SelectList(db.Contractors, "id_Contractor", "CompanyName", employee.id_contractor);
     return(View(employee));
 }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "UserID,FirstName,LastName,Email,Phone,JobRoleID, Password, confirmPassword")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.JobRoleID = new SelectList(db.Job_Role, "JobRoleID", "JobDescription", user.JobRoleID);
     return(View(user));
 }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "ScheduleID,DoctorID,LocationID,UserID,Time_In,Time_Out,HourCodeId,Amount")] Schedule schedule)
 {
     if (ModelState.IsValid)
     {
         db.Entry(schedule).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DoctorID   = new SelectList(db.Doctors, "DoctorId", "FirstName", schedule.DoctorID);
     ViewBag.HourCodeId = new SelectList(db.HourCodes, "CodeID", "CodeDescription", schedule.HourCodeId);
     return(View(schedule));
 }
Exemplo n.º 8
0
        public async Task <ActionResult> Edit([Bind(Include = "id_Timesheet,id_Customer,id_Contractor,id_Employee,id_WorkAssignment,StartTime,StopTime,Comments,CreatedAt,WorkComplete,LastModifiedAt,DeletedAt,Active,Latitude,Longitude")] Timesheet timesheet)
        {
            if (ModelState.IsValid)
            {
                db.Entry(timesheet).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.id_Contractor     = new SelectList(db.Contractors, "id_Contractor", "CompanyName", timesheet.id_Contractor);
            ViewBag.id_Customer       = new SelectList(db.Customers, "id_Customer", "CustomerName", timesheet.id_Customer);
            ViewBag.id_Employee       = new SelectList(db.Employees, "id_Employee", "FirstName", timesheet.id_Employee);
            ViewBag.id_WorkAssignment = new SelectList(db.WorkAssignments, "id_WorkAssignment", "Title", timesheet.id_WorkAssignment);
            return(View(timesheet));
        }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "LocationID,LocationName,SectionID")] Location location)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (var context = new TimesheetEntities())
             {
                 Location loc = context.Locations.Find(location.LocationID);
                 if (loc != null)
                 {
                     if (!(String.IsNullOrEmpty(location.LocationName) || (context.chkLocationNameExist(location.LocationName) && loc.LocationName != location.LocationName)))
                     {
                         db.Entry(location).State = EntityState.Modified;
                         db.SaveChanges();
                         return(RedirectToAction("Index"));
                     }
                     else
                     {
                         ViewBag.ValLocationName = String.IsNullOrEmpty(location.LocationName) ? "You have not entered a value for Location" : $"There already exist a Location named \"{location.LocationName}\"";
                     }
                 }
                 else
                 {
                     ViewBag.LocationName = $"This location could not be found in the database";
                 }
             }
         }
         ViewBag.SectionID = new SelectList(db.Sectors, "SectorName", "SectorName", location.SectionID);
     }
     catch (Exception ex)
     {
         ViewBag.SectionID       = new SelectList(db.Sectors, "SectorName", "SectorName", location.SectionID);
         ViewBag.ValLocationName = $"An error occured while updating this Location \n{ex.Message}";
     }
     return(View(location));
 }
Exemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "SectorName,SectionID")] Sector sector, string oldSectorName)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (var context = new TimesheetEntities())
             {
                 Sector sec = context.Sectors.Find(sector.SectionID);
                 if (sec != null)
                 {
                     if (!(String.IsNullOrEmpty(sector.SectorName) || (context.chkSectorNameExist(sector.SectorName) && sec.SectorName != sector.SectorName)))
                     {
                         db.Entry(sector).State = EntityState.Modified;
                         db.SaveChanges();
                         //db.updateSector(oldSectorName, sector.SectorName);
                         return(RedirectToAction("Index"));
                     }
                     else
                     {
                         ViewBag.ErrorValidation = String.IsNullOrEmpty(sector.SectorName) ? "You have not entered a value for Sector" : $"There already exist a Sector named \"{sector.SectorName}\"";
                     }
                 }
                 else
                 {
                     ViewBag.ErrorValidation = $"This sector ID {sector.SectionID}could not be found in the database";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ViewBag.ErrorValidation = $"An error occured during update {ViewBag.oldSectorName}. ({ex.Message})";
     }
     return(View(sector));
 }