public ActionResult Edit(RouteMileage model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                try
                {
                    CarraraSQL.RouteMileages.Attach(model);
                    CarraraSQL.RouteMileages.Remove(model);
                    CarraraSQL.SaveChanges();
                    TempData["Page.Title"] = "The Route Mileage Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Route Mileage Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (ModelState.IsValid)
            {
                CarraraSQL.Entry(model).State = EntityState.Modified;
                CarraraSQL.SaveChanges();
                TempData["Page.Title"] = "The Route Mileage Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Route Mileage Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #2
0
 public ActionResult EditPourDetail(PourDetailView model)
 {
     try
     {
         Mark mark = CarraraSQL.Marks.Find(model.MarkID);
         mark.JobID      = model.JobID;
         mark.MarkNumber = model.MarkNumber;
         mark.Width      = model.Width;
         mark.Length     = model.Length;
         mark.Thickness  = model.Thickness;
         mark.MarkTypeID = model.MarkTypeID;
         mark.Weight     = model.Weight;
         mark.SquareFeet = model.SquareFeet;
         PourDetail pourDetail = CarraraSQL.PourDetails.Find(model.PourDetailID);
         pourDetail.Quantity  = model.Quantity;
         pourDetail.MarkRange = model.MarkRange;
         pourDetail.Camber    = model.Camber;
         CarraraSQL.SaveChanges();
         return(Content("OK", "text/plain"));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
Example #3
0
 public ActionResult Edit(WeightFormulaType model)
 {
     if (model.Action == "Delete")
     {
         WeightFormulaType entity = CarraraSQL.WeightFormulaTypes.Find(model.WeightFormulaTypeID);
         if (entity.MarkTypes.Any())
         {
             return(Content("Whoops…The Weight Formula Type Is In Use And Was NOT Deleted!", "text/plain"));
         }
         try
         {
             CarraraSQL.WeightFormulaTypes.Remove(entity);
             CarraraSQL.SaveChanges();
             HttpContext.Cache.Remove("WeightFormulaTypesSelectList");
             return(Content("OK", "text/plain"));
         }
         catch (Exception ex)
         {
             string message = ex.Message;
             if (ex.InnerException != null)
             {
                 message = ex.InnerException.Message;
             }
             return(Content(string.Concat("Whoops…", message), "text/plain"));
         }
     }
     if (ModelState.IsValid)
     {
         CarraraSQL.Entry(model).State = EntityState.Modified;
         CarraraSQL.SaveChanges();
         HttpContext.Cache.Remove("WeightFormulaTypesSelectList");
         return(PartialView("Row", model));
     }
     return(ReturnError());
 }
Example #4
0
        public ActionResult Edit(Contact model)
        {
            Contact entity = CarraraSQL.Contacts.Find(model.ContactID);
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                if (entity.Jobs.Any() || entity.Loads.Any())
                {
                    Page.Title   = "The Contact Is In Use And Was NOT Deleted!";
                    Page.Message = "Set the Contact Type to Inactive if you do not intend to use this Contact again.";
                    return(View("Manage", model));
                }
                try
                {
                    CarraraSQL.Contacts.Attach(model);
                    CarraraSQL.Contacts.Remove(model);
                    CarraraSQL.SaveChanges();
                    HttpContext.Cache.Remove("IndependantDriversSelectList");
                    TempData["Page.Title"] = "The Contact Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Contact Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }

            if (ModelState.IsValid)
            {
                entity.StreetAddress = model.StreetAddress;
                entity.City          = model.City;
                entity.Company       = model.Company;
                entity.ContactTypeID = model.ContactTypeID;
                entity.DisplayName   = model.DisplayName;
                entity.EMail         = model.EMail;
                entity.FaxNumber     = model.FaxNumber;
                entity.FirstName     = model.FirstName;
                entity.HomePhone     = model.HomePhone;
                entity.LastName      = model.LastName;
                entity.MobilePhone   = model.MobilePhone;
                entity.Notes         = model.Notes;
                entity.State         = model.State;
                entity.WorkPhone     = model.WorkPhone;
                entity.Zip           = model.Zip;
                CarraraSQL.SaveChanges();
                Models.Search.Index.ContactsAsync();
                HttpContext.Cache.Remove("IndependantDriversSelectList");
                TempData["Page.Title"] = "The Contact Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Contact Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #5
0
        public ActionResult Edit(Employee model)
        {
            Employee             entity     = CarraraSQL.Employees.Find(model.EmployeeID);
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();
            Employee             existing   = CarraraSQL.Employees.FirstOrDefault(x => x.EmployeeNumber == model.EmployeeNumber && x.EmployeeID != model.EmployeeID);

            if (existing != null)
            {
                ModelState.AddModelError("", "That employee number is already in use by an active employee. Please use a unique employee number.");
            }
            if (TryValidateModel(model))
            {
                entity.BirthDate = model.BirthDate;
                entity.City      = model.City;
                entity.DefaultAssignmentTypeID = model.DefaultAssignmentTypeID;
                entity.DefaultCostCenterID     = model.DefaultCostCenterID;
                entity.DepartmentID            = model.DepartmentID;
                entity.DriverKey             = model.DriverKey;
                entity.EmergencyContactName  = model.EmergencyContactName;
                entity.EmergencyContactPhone = model.EmergencyContactPhone;
                entity.EmployeeNumber        = model.EmployeeNumber;
                entity.EmployeeStatusID      = model.EmployeeStatusID;
                entity.EndDate          = model.EndDate;
                entity.FirstName        = model.FirstName;
                entity.IsAdministrator  = model.IsAdministrator;
                entity.IsDriver         = model.IsDriver;
                entity.IsHourly         = model.IsHourly;
                entity.IsProjectManager = model.IsProjectManager;
                entity.IsRediMixVisible = model.IsRediMixVisible;
                entity.LastName         = model.LastName;
                entity.LocationID       = model.LocationID;
                entity.Mobile           = model.Mobile;
                entity.Phone            = model.Phone;
                entity.Rate             = model.Rate;
                entity.ShiftEndTime     = model.ShiftEndTime;
                entity.ShiftStartTime   = model.ShiftStartTime;
                entity.StartDate        = model.StartDate;
                entity.Street           = model.Street;
                entity.SSN           = model.SSN;
                entity.State         = model.State;
                entity.VacationHours = model.VacationHours;
                entity.VehicleID     = model.VehicleID;
                entity.Zip           = model.Zip;
                CarraraSQL.SaveChanges();
                Search.Index.EmployeesAsync();
                HttpContext.Cache.Remove("DriversSelectList");
                HttpContext.Cache.Remove("EmployeesSelectList");
                TempData["Page.Title"] = "The Employee Was Updated Successfully!";
                return(RedirectToAction("Edit", parameters.CopyAndAdd("guid", model.EmployeeID)));
            }
            Page.Title   = "The Employee Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #6
0
        public ActionResult Add(WeightFormulaType model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (ModelState.IsValid)
            {
                CarraraSQL.WeightFormulaTypes.Add(model);
                CarraraSQL.SaveChanges();
                HttpContext.Cache.Remove("WeightFormulaTypesSelectList");
                return(PartialView("Row", model));
            }
            return(ReturnError());
        }
Example #7
0
        public ActionResult AddPour(Pour model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (ModelState.IsValid)
            {
                CarraraSQL.Pours.Add(model);
                CarraraSQL.SaveChanges();
                TempData["Page.Title"] = "The Pour Was Added Successfully!";
                return(RedirectToAction("Index", parameters));
            }
            // Failure is always an option...
            Page.Title   = "The Pour Was NOT Added!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #8
0
        public ActionResult Edit(Models.CarraraSQL.Route model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                Models.CarraraSQL.Route entity = CarraraSQL.Routes.Find(model.RouteID);
                if (entity.Jobs.Any() ||
                    entity.Loads.Any() ||
                    entity.RouteMileages.Any())
                {
                    Page.Title   = "The Route Is In Use And Was NOT Deleted!";
                    Page.Message = "Set the Route to Inactive if you do not intend to use this Route again.";
                    return(View("Manage", model));
                }
                try
                {
                    CarraraSQL.Routes.Attach(model);
                    CarraraSQL.Routes.Remove(model);
                    CarraraSQL.SaveChanges();
                    HttpContext.Cache.Remove("RoutesSelectList");
                    TempData["Page.Title"] = "The Route Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Route Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (model.Action == "Mileage")
            {
                return(RedirectToAction("Index", "RouteMileage", new { guid = model.RouteID }));
            }
            if (ModelState.IsValid)
            {
                CarraraSQL.Entry(model).State = EntityState.Modified;
                CarraraSQL.SaveChanges();
                TempData["Page.Title"] = "The Route Was Updated Successfully";
                HttpContext.Cache.Remove("RoutesSelectList");
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Route Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #9
0
        public ActionResult Add(Contact model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (ModelState.IsValid)
            {
                CarraraSQL.Contacts.Add(model);
                CarraraSQL.SaveChanges();
                HttpContext.Cache.Remove("IndependantDriversSelectList");
                TempData["Page.Title"] = "The Contact Was Added Successfully!";
                return(RedirectToAction("Index", parameters));
            }
            // Failure is always an option...
            Page.Title   = "The Contact Was NOT Added!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #10
0
        public ActionResult Edit(Job model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                Job entity = CarraraSQL.Jobs.Find(model.JobID);
                if (entity.HoursAssignments.Any() ||
                    entity.JobSiteLocations.Any() ||
                    entity.Loads.Any() ||
                    entity.Marks.Any() ||
                    entity.NonConformingReports.Any() ||
                    entity.Pours.Any())
                {
                    Page.Title   = "The Job Is In Use And Was NOT Deleted!";
                    Page.Message = "Set the Job Type to Completed, On Hold or Cancelled if you do not intend to use this Job again.";
                    return(View("Manage", model));
                }
                try
                {
                    CarraraSQL.Jobs.Attach(model);
                    CarraraSQL.Jobs.Remove(model);
                    CarraraSQL.SaveChanges();
                    HttpContext.Cache.Remove("JobsSelectList");
                    TempData["Page.Title"] = "The Job Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Job Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (ModelState.IsValid)
            {
                CarraraSQL.Entry(model).State = EntityState.Modified;
                CarraraSQL.SaveChanges();
                Search.Index.JobsAsync();
                HttpContext.Cache.Remove("JobsSelectList");
                TempData["Page.Title"] = "The Job Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Job Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #11
0
 public ActionResult AddPourDetail(PourDetailView model)
 {
     try
     {
         Mark mark = new Mark
         {
             JobID      = model.JobID,
             MarkNumber = model.MarkNumber,
             Width      = model.Width,
             Length     = model.Length,
             Thickness  = model.Thickness,
             MarkTypeID = model.MarkTypeID,
             Weight     = model.Weight,
             SquareFeet = model.SquareFeet
         };
         CarraraSQL.Marks.Add(mark);
         PourDetail pourDetail = new PourDetail
         {
             Quantity  = model.Quantity,
             MarkRange = model.MarkRange,
             Camber    = model.Camber,
             MarkID    = mark.MarkID,
             PourID    = model.PourID
         };
         CarraraSQL.PourDetails.Add(pourDetail);
         CarraraSQL.SaveChanges();
         Pour pour = CarraraSQL.Pours.Find(model.PourID);
         return(PartialView("_PourDetail", new PourDetail
         {
             PourID = model.PourID,
             Pour = pour,
             DefaultJobID = pour.DefaultJobID,
             DefaultMarkTypeID = pour.DefaultMarkTypeID
         }));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
Example #12
0
 public ActionResult AddTimeClockEntry(TimeClockEntry model)
 {
     try
     {
         CarraraSQL.TimeClockEntries.Add(model);
         CarraraSQL.SaveChanges();
         return(Content("OK", "text/plain"));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
        public ActionResult Edit(Department model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                Department entity = CarraraSQL.Departments.Find(model.DepartmentID);
                if (entity.Employees.Any() ||
                    entity.HoursAssignments.Any() ||
                    entity.Loads.Any() ||
                    entity.TimeClockPermissions.Any())
                {
                    Page.Title   = "The Department Is In Use And Was NOT Deleted!";
                    Page.Message = "Set the Department to Inactive if you do not intend to use this Department again.";
                    return(View("Manage", model));
                }

                try
                {
                    CarraraSQL.Departments.Attach(model);
                    CarraraSQL.Departments.Remove(model);
                    CarraraSQL.SaveChanges();
                    HttpContext.Cache.Remove("DepartmentsSelectList");
                    TempData["Page.Title"] = "The Department Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Department Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (ModelState.IsValid)
            {
                CarraraSQL.Entry(model).State = EntityState.Modified;
                CarraraSQL.SaveChanges();
                HttpContext.Cache.Remove("DepartmentsSelectList");
                TempData["Page.Title"] = "The Department Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Department Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
 public ActionResult DeleteLoad(int guid)
 {
     try
     {
         Load load = CarraraSQL.Loads.Find(guid);
         CarraraSQL.Loads.Remove(load);
         CarraraSQL.SaveChanges();
         return(Content("OK", "text/plain"));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
Example #15
0
 public ActionResult DeleteNonConformingReport(int guid)
 {
     try
     {
         NonConformingReport nonConformingReport = CarraraSQL.NonConformingReports.Find(guid);
         CarraraSQL.NonConformingReports.Remove(nonConformingReport);
         CarraraSQL.SaveChanges();
         return(Content("OK", "text/plain"));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
Example #16
0
 public ActionResult DeletePourDetail(int guid)
 {
     try
     {
         PourDetail pourDetail = CarraraSQL.PourDetails.Find(guid);
         Mark       mark       = CarraraSQL.Marks.Find(pourDetail.MarkID);
         CarraraSQL.Marks.Remove(mark);
         CarraraSQL.PourDetails.Remove(pourDetail);
         CarraraSQL.SaveChanges();
         return(Content("OK", "text/plain"));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
Example #17
0
 public ActionResult AddNonConformingReport(NonConformingReport model)
 {
     try
     {
         CarraraSQL.NonConformingReports.Add(model);
         CarraraSQL.SaveChanges();
         Pour pour = CarraraSQL.Pours.Find(model.PourID);
         return(PartialView("_NonConformingReport", new NonConformingReport {
             JobID = pour.DefaultJobID.Value,
             PourID = pour.PourID
         }));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
Example #18
0
        public ActionResult Edit(JobStatu model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                JobStatu entity = CarraraSQL.JobStatus.Find(model.JobStatusID);
                if (entity.Jobs.Any())
                {
                    Page.Title   = "The Job Status Is In Use And Was NOT Deleted!";
                    Page.Message = "Set the Job Status to Inactive if you do not intend to use this Job Status again.";
                    return(View("Manage", model));
                }
                try
                {
                    CarraraSQL.JobStatus.Attach(model);
                    CarraraSQL.JobStatus.Remove(model);
                    CarraraSQL.SaveChanges();
                    TempData["Page.Title"] = "The Job Status Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Job Status Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (ModelState.IsValid)
            {
                CarraraSQL.Entry(model).State = EntityState.Modified;
                CarraraSQL.SaveChanges();
                TempData["Page.Title"] = "The Job Status Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Job Status Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #19
0
        public ActionResult Add(Employee model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();
            Employee             existing   = CarraraSQL.Employees.FirstOrDefault(x => x.EmployeeNumber == model.EmployeeNumber);

            if (existing != null)
            {
                ModelState.AddModelError("", "This employee number is already in use by an active employee. Please use a unique employee number.");
            }
            if (TryValidateModel(model))
            {
                CarraraSQL.Employees.Add(model);
                CarraraSQL.SaveChanges();
                HttpContext.Cache.Remove("DriversSelectList");
                HttpContext.Cache.Remove("EmployeesSelectList");
                TempData["Page.Title"] = "The Employee Was Added Successfully!";
                return(RedirectToAction("Index", parameters));
            }
            // Failure is always an option...
            Page.Title   = "The Employee Was NOT Added!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #20
0
        public ActionResult EditPour(Pour model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            Pour entity = CarraraSQL.Pours.Find(model.PourID);

            if (model.Action == "Delete")
            {
                try
                {
                    CarraraSQL.Pours.Attach(model);
                    CarraraSQL.Pours.Remove(model);
                    CarraraSQL.SaveChanges();
                    TempData["Page.Title"] = "The Pour Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Pour Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (ModelState.IsValid)
            {
                entity.BedID             = model.BedID;
                entity.MixID             = model.MixID;
                entity.Thickness         = model.Thickness;
                entity.ThreeInchStrands  = model.ThreeInchStrands;
                entity.PourDate          = model.PourDate;
                entity.PourTime          = model.PourTime;
                entity.YardsConcrete     = model.YardsConcrete;
                entity.Location          = model.Location;
                entity.FiveInchStrands   = model.FiveInchStrands;
                entity.PourStatusID      = model.PourStatusID;
                entity.YardsGrout        = model.YardsGrout;
                entity.SlipNumber        = model.SlipNumber;
                entity.SixInchStrands    = model.SixInchStrands;
                entity.JackNumber        = model.JackNumber;
                entity.PourScheduleNotes = model.PourScheduleNotes;
                entity.Notes             = model.Notes;

                entity.DefaultJobID      = model.DefaultJobID;
                entity.DefaultMarkTypeID = model.DefaultMarkTypeID;

                entity.Air                 = model.Air;
                entity.Slump               = model.Slump;
                entity.VSI                 = model.VSI;
                entity.UnitWeight          = model.UnitWeight;
                entity.Yield               = model.Yield;
                entity.AmbientTemperature  = model.AmbientTemperature;
                entity.ConcreteTemperature = model.ConcreteTemperature;
                entity.NumberOfCylinders   = model.NumberOfCylinders;
                entity.Workability         = model.Workability;
                entity.Weather             = model.Weather;


                entity.ReleaseTest1       = model.ReleaseTest1;
                entity.ReleaseTest2       = model.ReleaseTest2;
                entity.ReleaseTestAverage = ((model.ReleaseTest1.HasValue ? model.ReleaseTest1.Value : 0) + (model.ReleaseTest2.HasValue ? model.ReleaseTest2.Value : 0)) / 2;
                entity.ReleaseTestDate    = model.ReleaseTestDate;

                entity.C28DayTest1       = model.C28DayTest1;
                entity.C28DayTest2       = model.C28DayTest2;
                entity.C28DayTestAverage = ((model.C28DayTest1.HasValue ? model.C28DayTest1.Value : 0) + (model.C28DayTest2.HasValue ? model.C28DayTest2.Value : 0)) / 2;
                entity.C28DayTestDate    = model.C28DayTestDate;

                entity.OtherTest1       = model.OtherTest1;
                entity.OtherTest2       = model.OtherTest2;
                entity.OtherTestAverage = ((model.OtherTest1.HasValue ? model.OtherTest1.Value : 0) + (model.OtherTest2.HasValue ? model.OtherTest2.Value : 0)) / 2;
                entity.OtherTestDate    = model.OtherTestDate;

                entity.SpecAir             = model.SpecAir;
                entity.SpecAirError        = model.SpecAirError;
                entity.SpecMaxSlump        = model.SpecMaxSlump;
                entity.SpecReleaseStrength = model.SpecReleaseStrength;
                entity.Spec28DayStrength   = model.Spec28DayStrength;
                entity.SpecNotes           = model.SpecNotes;
                CarraraSQL.SaveChanges();
                TempData["Page.Title"] = "The Pour Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Pour Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #21
0
        public ActionResult Edit(Vehicle model)
        {
            Vehicle entity = CarraraSQL.Vehicles.Find(model.VehicleID);
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                try
                {
                    CarraraSQL.Vehicles.Attach(model);
                    CarraraSQL.Vehicles.Remove(model);
                    CarraraSQL.SaveChanges();
                    HttpContext.Cache.Remove("TractorsSelectList");
                    HttpContext.Cache.Remove("TrailersSelectList");
                    HttpContext.Cache.Remove("VehiclesSelectList");
                    TempData["Page.Title"] = "The Vehicle Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Vehicle Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (model.Action == "Maintenance")
            {
                return(RedirectToAction("Index", "VehicleMaintenance", new { vehicle = model.VehicleID }));
            }
            if (ModelState.IsValid)
            {
                entity.IsActive            = model.IsActive;
                entity.CurrentMeterReading = model.CurrentMeterReading;
                entity.DefaultDriverID     = model.DefaultDriverID;
                entity.EZPass = model.EZPass;
                entity.GrossAxleWeightRating    = model.GrossAxleWeightRating;
                entity.GrossVehicleWeightRating = model.GrossVehicleWeightRating;
                entity.IsOnRoad               = model.IsOnRoad;
                entity.LastGrease             = model.LastGrease;
                entity.LastOil                = model.LastOil;
                entity.LastService            = model.LastService;
                entity.Length                 = model.Length;
                entity.LocationID             = model.LocationID;
                entity.Make                   = model.Make;
                entity.VehicleName            = model.VehicleName;
                entity.NextGrease             = model.NextGrease;
                entity.NextOil                = model.NextOil;
                entity.NextService            = model.NextService;
                entity.NumberOfAxles          = model.NumberOfAxles;
                entity.Registration           = model.Registration;
                entity.RegistrationDate       = model.RegistrationDate;
                entity.RegistrationExpiration = model.RegistrationExpiration;
                entity.ShouldExportUsage      = model.ShouldExportUsage;
                entity.TrailerType            = model.TrailerType;
                entity.VehicleCode            = model.VehicleCode;
                entity.VehicleTypeID          = model.VehicleTypeID;
                entity.VIN    = model.VIN;
                entity.Weight = model.Weight;
                entity.Year   = model.Year;
                CarraraSQL.SaveChanges();
                Search.Index.VehiclesAsync();
                HttpContext.Cache.Remove("TractorsSelectList");
                HttpContext.Cache.Remove("TrailersSelectList");
                HttpContext.Cache.Remove("VehiclesSelectList");
                TempData["Page.Title"] = "The Vehicle Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Vehicle Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Example #22
0
 public ActionResult EditTimeClockEntry(TimeClockEntry model)
 {
     if (ModelState.IsValid)
     {
         TimeClockEntry entity = CarraraSQL.TimeClockEntries.Find(model.TimeClockEntryID);
         if (!entity.Approved && model.Approved)
         {
             entity.ApprovedBy       = AspNetUser.FullName;
             entity.ApprovedDateTime = DateTime.Now;
         }
         else if (!model.Approved)
         {
             entity.ApprovedBy       = string.Empty;
             entity.ApprovedDateTime = null;
         }
         try
         {
             string   converted     = model.ClockInDate.Value.ToString("MM/dd/yy") + " " + model.ClockInTime.Value.ToString("h:mm:ss tt");
             DateTime convertedDate = Convert.ToDateTime(converted);
             entity.ClockIn = convertedDate;
         }
         catch { }
         try
         {
             string   converted     = model.ClockOutDate.Value.ToString("MM/dd/yy") + " " + model.ClockOutDate.Value.ToString("h:mm:ss tt");
             DateTime convertedDate = Convert.ToDateTime(converted);
             entity.ClockOut = convertedDate;
         }
         catch { }
         entity.HoursWorked     = model.HoursWorked;
         entity.CostCenterID    = model.CostCenterID;
         entity.DrivenVehicleID = model.DrivenVehicleID;
         entity.Lunch           = model.Lunch;
         entity.Notes           = model.Notes;
         CarraraSQL.SaveChanges();
         return(Content(string.Concat(
                            "<td>", entity.Employee.LastName, ", ", entity.Employee.FirstName, "</td>",
                            "<td class=\"numeric\">", entity.StartTime.HasValue ? entity.StartTime.Value.ToShortTimeString() : string.Empty, "</td>",
                            "<td class=\"numeric\">", entity.DayOfWeek, "</td>",
                            "<td class=\"numeric\">", entity.ClockIn, "</td>",
                            "<td class=\"numeric\">", entity.OriginalClockIn, "</td>",
                            "<td class=\"numeric\">",
                            entity.Lunch ?
                            string.Concat("<input checked=\"checked\" id=\"lunch_", entity.TimeClockEntryID, "\" name=\"lunch_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />") :
                            string.Concat("<input id=\"lunch_", entity.TimeClockEntryID, "\" name=\"lunch_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />"),
                            "</td>",
                            "<td class=\"numeric\">", entity.ClockOut, "</td>",
                            "<td class=\"numeric\">", entity.OriginalClockOut, "</td>",
                            "<td class=\"numeric\">", entity.HoursWorked.HasValue ? entity.HoursWorked.Value.ToString("F2") : string.Empty, "</td>",
                            "<td>", entity.Employee.DepartmentID.HasValue ? entity.Employee.Department.DepartmentName : string.Empty, " - ", entity.CostCenterID, "</td>",
                            "<td>", entity.DrivenVehicleID.HasValue ? entity.Vehicle.VehicleCode : string.Empty, "</td>",
                            "<td class=\"numeric\">",
                            entity.ApprovedDateTime.HasValue ?
                            string.Concat("<input checked=\"checked\" id=\"approved_", entity.TimeClockEntryID, "\" name=\"approved_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />") :
                            string.Concat("<input id=\"approved_", entity.TimeClockEntryID, "\" name=\"approved_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />"),
                            "</td>",
                            "<td class=\"numeric\">", entity.ApprovedDateTime, "</td>",
                            "<td>", entity.ApprovedBy, "</td>",
                            "<td class=\"numeric\">", entity.Notes, "</td>",
                            "<td class=\"numeric error\">", entity.Status, "</td>"
                            ), "text/plain"));
     }
     return(ReturnError());
 }