public ActionResult EditEmployee(Employee employee) { if (ModelState.IsValid) { using (VIMSDBContext context = new VIMSDBContext()) { Employee current_employee = context.Employees.Find(employee.Id); if (employee != null && (bool)employee.Active) // BKP fix should not be nullable { int count = context.Employees. Where(m => m.UserName == employee.UserName && m.Id != employee.Id). Count(); if (count == 0) { //employee.UpdatedBy = admin_id; employee.UpdatedDt = System.DateTime.Now; context.Entry(current_employee).CurrentValues.SetValues(employee); context.SaveChanges(); return(View("EditemployeeConfirmation", employee)); } } } } return(View("Error")); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,UserName,Password,Admin,Active,CreatedBy,CreatedDt,UpdatedBy,UpdatedDt")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
//public ActionResult VolunteerClockedInOut(int locationId, string userName) public ActionResult VolunteerClockedInOut() { VIMSDBContext context = ((Repository <Volunteer>)volunteerInfoRepository).Context; Volunteer volunteer = (Volunteer)TempData["VolunteerInfo"]; Location location = ((Location)TempData["Location"]); context.Entry(volunteer).State = EntityState.Modified; // reload after request VolunteerTimeClock clockInfo = volunteerInfoRepository.GetClockedInInfo(volunteer); VolunteerPhoto photo = volunteerInfoRepository.GetLastPhotoInfo(volunteer); VolunteerProfile profile = volunteerInfoRepository.GetDefaultProfileInfo(volunteer.Id); if (clockInfo != null) { // was clocked in so clock out clockInfo.ClockOut = DateTime.Now; clockInfo.ClockOutPhoto = photo != null ? photo.Path : null; context.SaveChanges(); //BKP todo, merge with repo code } else { // clock in VolunteerTimeClock clockIn = new VolunteerTimeClock(); clockIn.VolunteerProfile = profile; clockIn.LocationId = location.Id; clockIn.ClockIn = DateTime.Now; clockIn.LocationId = ViewBag.LocationId; clockIn.ClockInPhoto = photo != null ? photo.Path : null; clockIn.CreatedBy = null; clockIn.CreatedDt = DateTime.Now; volunteer.VolunteerTimeClocks.Add(clockIn); context.SaveChanges(); //BKP todo, merge with repo code } // build model for view VolunteerClockedInOutViewModel model = new VolunteerClockedInOutViewModel(); model.isClockedIn = (clockInfo == null); // now!, clocked in model.Volunteer = volunteer; model.LocationId = (int)location.Id; model.LocationName = location.Name; model.TimeLogged = VolunteerClockedInOutViewModel.GetHoursLogged(volunteerInfoRepository.GetVolunteersCompletedInOutInfos(volunteer)); model.RecentClockInformation = volunteerInfoRepository.GetVolunteersRecentClockInOutInfos(volunteer, Util.TJSConstants.RECENT_LIST_LEN); model.CaseNumber = profile != null ? profile.CaseNumber : "NA"; model.TimeNeeded = profile != null ? new TimeSpan((short)profile.Volunteer_Hours_Needed, 0, 0) : new TimeSpan(0, 0, 0); return(View(model)); }
public ActionResult UpdateLocation(EditLocationsViewModel model) { if (ModelState.IsValid) { using (VIMSDBContext context = new VIMSDBContext()) { //todo //model.Location.UpdatedBy = "0"; //model.Location.UpdatedDt = System.DateTime.Now; Location location = context.Locations.Find(model.Location.Id); context.Entry(location).CurrentValues.SetValues(model.Location); context.SaveChanges(); } } return(View(model.Location)); }
public ActionResult VolunteerUpdateAccount(Volunteer volunteer, int locationId) { if (ModelState.IsValid) { using (VIMSDBContext context = new VIMSDBContext()) { Volunteer info = context.Volunteers.Find(volunteer.Id); context.Entry(info).CurrentValues.SetValues(volunteer); context.SaveChanges(); } return(RedirectToAction("VolunteerLookUp", "VolunteerClockTime", new { locationId = locationId })); } return(View("VolunteerEditAccount", volunteer)); }
public ActionResult VolunteerInformation(Volunteer volunteer) { if (ModelState.IsValid) { using (VIMSDBContext context = new VIMSDBContext()) { Volunteer info = context.Volunteers.Find(volunteer.Id); if (info != null) { context.Entry(info).CurrentValues.SetValues(volunteer); context.SaveChanges(); return(View("VolunteerInformationConfirmation")); } } } return(View("Error")); }
public ActionResult UndoEditOrganization(Organization organization) { if (ModelState.IsValid) { using (VIMSDBContext context = new VIMSDBContext()) { Organization current_organization = context.Organizations.Find(organization.Id); if (organization != null && (bool)organization.Active) // BKP fix should not be nullable { int count = context.Organizations. Where(m => m.Name == organization.Name && m.Id != organization.Id). Count(); if (count == 0) { context.Entry(current_organization).CurrentValues.SetValues(organization); context.SaveChanges(); return(View("UndoEditOrganizationConfirmation")); } } } } return(View("Error")); }