// GET: ProjectDetails public ActionResult Index(string projectID) { Models.Project myModel = new Models.Project(); CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (projectID != null) { var intProID = Int32.Parse(projectID); var myProject = db.Projects.Where(i => i.ProjectID == intProID).FirstOrDefault(); var mytypeID = db.Project_Type.Where(i => i.TypeID == myProject.TypeID).FirstOrDefault(); var myUserID = db.Users.Where(i => i.UserID == myProject.UserID).FirstOrDefault(); myModel.ProjectID = myProject.ProjectID; myModel.ProjectName = myProject.ProjectName; myModel.StartDate = myProject.StartDate; myModel.ExpectedFinishDate = myProject.ExpectedFinishDate; myModel.Finished = myProject.Finished; myModel.ProjectDescription = myProject.ProjectDescription; myModel.TypeID = mytypeID.TypeID; myModel.UserID = myUserID.UserID; myModel.TypeName = db.Project_Type.Where(i => i.TypeID == mytypeID.TypeID).FirstOrDefault().TypeName; myModel.Initials = db.Users.Where(i => i.UserID == myUserID.UserID).FirstOrDefault().Initials; myModel.LastName = db.Users.Where(i => i.UserID == myUserID.UserID).FirstOrDefault().LastName; } return(View(myModel)); }
// GET: AddBuilding public ActionResult Index() { var db = new CodeFirst.CodeFirst(); var building = new Models.Building(); return(View(building)); }
// GET: ModifyFunderOrg public ActionResult Index(string funderOrgID) { CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (funderOrgID != null) { Models.Funder_Org myModel = new Models.Funder_Org(); var intFundOrgID = Int32.Parse(funderOrgID); var myFunderOrg = db.Funder_Org.Where(i => i.FunderOrgID == intFundOrgID).FirstOrDefault(); myModel.FunderOrgID = myFunderOrg.FunderOrgID; myModel.OrgName = myFunderOrg.OrgName; myModel.ContactNumber = myFunderOrg.ContactNumber; myModel.EmailAddress = myFunderOrg.EmailAddress; myModel.Bank = myFunderOrg.Bank; myModel.AccountNumber = myFunderOrg.AccountNumber; myModel.BranchCode = myFunderOrg.BranchCode; myModel.StreetAddress = myFunderOrg.StreetAddress; myModel.City = myFunderOrg.City; myModel.AreaCode = myFunderOrg.AreaCode; myModel.Thanked = myFunderOrg.Thanked; myModel.TypeID = myFunderOrg.TypeID; myModel.ProjectID = myFunderOrg.ProjectID; myModel.FunderTypes = db.Funder_Type.ToList(); myModel.Project = db.Projects.ToList(); return(View(myModel)); } Models.Funder_Org model = new Models.Funder_Org(); return(View(model)); }
// GET: AddDonorOrg public ActionResult Index() { var db = new CodeFirst.CodeFirst(); var DonorOrg = new Models.Donor_Org(); return(View(DonorOrg)); }
public JsonResult GetScheduleEvents() { using (CodeFirst.CodeFirst db = new CodeFirst.CodeFirst()) { db.Configuration.LazyLoadingEnabled = false; var events = db.Venue_Schedule_Line.ToList(); var newData = (from e in events select new { start = e.StartTime, end = e.EndTime, dow = e.DateAvailable == "Sunday" ? 0 : e.DateAvailable == "Monday" ? 1 : e.DateAvailable == "Tuesday" ? 2 : e.DateAvailable == "Wednesday" ? 3 : e.DateAvailable == "Thursday" ? 4 : e.DateAvailable == "Friday" ? 5 : e.DateAvailable == "Saturday" ? 6 : -1 }) .ToList(); var myResult = new JsonResult(); myResult = new JsonResult { Data = newData, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; db.Configuration.LazyLoadingEnabled = false; return(Json(newData, JsonRequestBehavior.AllowGet)); } }
public ActionResult Upload([Bind(Prefix = "")] Models.EFTR model, HttpPostedFileBase file) { var db = new CodeFirst.CodeFirst(); //array of allowed extensions var allowedExtensions = new[] { ".pdf" }; //checking extension of file uploaded var checkExtension = Path.GetExtension(file.FileName).ToLower(); //check if does not contain the extension (not png/jpg/jpeg) var myReq = db.EFT_Requisition.Where(v => v.RequisitionID == model.RequisitionID).SingleOrDefault(); if (!allowedExtensions.Contains(checkExtension)) { ViewBag.Error = "Only PDF Files are allowed."; return(View("Index", model)); } if (file.ContentLength > 8 * 1024 * 1024) { ViewBag.Error = "File too big!"; } if (ViewBag.Error == null) { if (myReq != null) { string path = Path.Combine(Server.MapPath("~/Files"), Path.GetFileName(file.FileName)); file.SaveAs(path); myReq.ReceiptFile = "~/Files/" + file.FileName; db.SaveChanges(); } TempData["js"] = "myUpdateSuccess()"; return(RedirectToAction("Index", "EFTR")); } return(View("Index", model)); }
// GET: ModifySupplier public ActionResult Index(string SupplierID) { CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); Models.Supplier myModel = new Models.Supplier(); if (SupplierID != null) { var intSupplierID = Int32.Parse(SupplierID); var mySupplier = db.Suppliers.Where(i => i.SupplierID == intSupplierID).FirstOrDefault(); myModel.SupplierID = mySupplier.SupplierID; myModel.Name = mySupplier.Name; myModel.VATNumber = mySupplier.VATNumber; myModel.EmailAddress = mySupplier.EmailAddress; myModel.ContactNumber = mySupplier.ContactNumber; myModel.Bank = mySupplier.Bank; myModel.AccountNumber = mySupplier.AccountNumber; myModel.BranchCode = mySupplier.BranchCode; myModel.POAddress = mySupplier.POAddress; myModel.POCity = mySupplier.POCity; myModel.POAreaCode = mySupplier.POAreaCode; return(View(myModel)); } return(View(myModel)); }
// GET: EFTRDetails public ActionResult Index(string requisitionID) { Models.EFTR myModel = new Models.EFTR(); CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (requisitionID != null) { var intEFTRid = Int32.Parse(requisitionID); var myEFTR = db.EFT_Requisition.Where(i => i.RequisitionID == intEFTRid).FirstOrDefault(); var mySupplierID = db.Suppliers.Where(i => i.SupplierID == myEFTR.SupplierID).FirstOrDefault(); var myUserID = db.Users.Where(i => i.UserID == myEFTR.UserID).FirstOrDefault(); var myProjectID = db.Projects.Where(i => i.ProjectID == myEFTR.ProjectID).FirstOrDefault(); myModel.RequisitionID = myEFTR.RequisitionID; myModel.Date = myEFTR.Date; myModel.ApprovedCEO = myEFTR.ApprovedCEO; myModel.ApprovedProjectManger = myEFTR.ApprovedProjectManger; myModel.ReceiptFile = myEFTR.ReceiptFile; myModel.SupplierID = mySupplierID.SupplierID; myModel.ProjectID = myProjectID.ProjectID; myModel.UserID = myUserID.UserID; myModel.Name = db.Suppliers.Where(i => i.SupplierID == mySupplierID.SupplierID).FirstOrDefault().Name; myModel.ProjectName = db.Projects.Where(i => i.ProjectID == myProjectID.ProjectID).FirstOrDefault().ProjectName; myModel.Initials = db.Users.Where(i => i.UserID == myUserID.UserID).FirstOrDefault().Initials; myModel.LastName = db.Users.Where(i => i.UserID == myUserID.UserID).FirstOrDefault().LastName; myModel.TotalAmount = myEFTR.TotalAmount; myModel.Lines = myEFTR.EFT_Requisition_Line.ToList(); } return(View(myModel)); }
public ActionResult Modify([Bind(Prefix = "")] Models.RepairPerson model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { var person = db.RepairPersons.Where(v => v.RepPersonID == model.RepPersonID).SingleOrDefault(); if (person != null) { person.RepPersonID = model.RepPersonID; person.Name = model.Name; person.EmailAddress = model.EmailAddress; person.Bank = model.Bank; person.AccountNumber = model.AccountNumber; person.BranchCode = model.BranchCode; db.SaveChanges(); } TempData["js"] = "myUpdateSuccess()"; return(RedirectToAction("Index", "RepairPersons")); } return(View("Index", model)); }
public ActionResult NotifyFunderTY() { var db = new CodeFirst.CodeFirst(); var orgs = new Dictionary <string, string>(); var people = new Dictionary <string, string>(); var funderOrgs = db.Funder_Org.Where(d => d.Thanked == false); if (funderOrgs.ToList().Count > 0) { foreach (var item in funderOrgs) { orgs.Add(item.OrgName, item.EmailAddress); } } var funderPeople = db.Funder_Person.Where(d => d.Thanked == false); if (funderPeople.ToList().Count > 0) { foreach (var item in funderPeople) { people.Add(item.FirstName + " " + item.LastName, item.PersonalEmail); } } if (orgs.Count > 0 || people.Count > 0) { SendFunderEmail("Funders need thanking", "The following Funders need thanking: <br>", orgs, people); } return(new EmptyResult()); }
public ActionResult Create([Bind(Prefix = "")] Models.AccessLevel model) { if (ModelState.IsValid) { var db = new CodeFirst.CodeFirst(); if (db.Access_Level.Count() > 0) { var item = db.Access_Level.OrderByDescending(a => a.AccessLevelID).FirstOrDefault(); db.Access_Level.Add(new CodeFirst.Access_Level { AccessLevelID = item.AccessLevelID + 1, LevelName = model.LevelName, LevelDescription = model.LevelDescription }); } else { db.Access_Level.Add(new CodeFirst.Access_Level { AccessLevelID = 1, LevelName = model.LevelName, LevelDescription = model.LevelDescription }); } db.SaveChanges(); model.JavaScriptToRun = "mySuccess()"; TempData["model"] = model; return(RedirectToAction("Index", "AccessLevels")); } return(View("Index", model)); }
public ActionResult NotifyVehicleServiceInterval() { var db = new CodeFirst.CodeFirst(); var vehicles = new Dictionary <string, string>(); var services = db.Services.Where(d => (d.ServiceDate.AddMonths(d.Vehicle.ServiceIntervalInMonths.Value) - d.ServiceDate).Days < 7); /*if (funderOrgs.ToList().Count > 0) * { * foreach (var item in funderOrgs) * { * orgs.Add(item.OrgName, item.EmailAddress); * } * } * * var funderPeople = db.Funder_Person.Where(d => d.Thanked == false); * * if (funderPeople.ToList().Count > 0) * { * foreach (var item in funderPeople) * { * people.Add(item.FirstName + " " + item.LastName, item.PersonalEmail); * } * } * * if (orgs.Count > 0 || people.Count > 0) * { * SendFunderEmail("Funders need thanking", "The following Funders need thanking: <br>", orgs, people); * }*/ return(new EmptyResult()); }
public ActionResult NotifyDonorTY() { var db = new CodeFirst.CodeFirst(); var orgs = new Dictionary <string, string>(); var people = new Dictionary <string, string>(); var checkDate = DateTime.Today.AddMonths(-2); var donations = db.Donations.Where(d => d.DateDate < checkDate); if (donations.ToList().Count > 0) { foreach (var item in donations) { if (item.DonorOrgID != null && item.Donor_Org.Thanked == false) { orgs.Add(item.Donor_Org.OrgName, item.Donor_Org.ContactEmail); } if (item.DonorPID != null && item.Donor_Person.Thanked == false) { people.Add(item.Donor_Person.FirstName + " " + item.Donor_Person.SecondName, item.Donor_Person.PersonalEmail); } } if (orgs.Count > 0 || people.Count > 0) { SendEmail("Donors need thanking", "The following Donors need thanking: <br>", orgs, people); } } return(new EmptyResult()); }
public ActionResult Create([Bind(Prefix = "")]Models.VehicleType model) { if (ModelState.IsValid) { var db = new CodeFirst.CodeFirst(); if (db.Vehicle_Type.Count() > 0) { var item = db.Vehicle_Type.OrderByDescending(a => a.TypeID).FirstOrDefault(); db.Vehicle_Type.Add(new CodeFirst.Vehicle_Type { TypeID = item.TypeID + 1, Name = model.Name, Description = model.Description, }); } else { db.Vehicle_Type.Add(new CodeFirst.Vehicle_Type { TypeID = 1, Name = model.Name, Description = model.Description, }); } db.SaveChanges(); model.JavaScriptToRun = "mySuccess()"; TempData["model"] = model; return RedirectToAction("Index", "VehicleTypes"); } return View("Add", model); }
// GET: AddSupplier public ActionResult Index() { var db = new CodeFirst.CodeFirst(); var supplier = new Models.Supplier(); return(View(supplier)); }
public ActionResult Modify([Bind(Prefix = "")] Models.Donor_Org model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { var DonorOrg = db.Donor_Org.Where(v => v.DonorOrgID == model.DonorOrgID).SingleOrDefault(); if (DonorOrg != null) { DonorOrg.DonorOrgID = model.DonorOrgID; DonorOrg.OrgName = model.OrgName; DonorOrg.ContactNum = model.ContactNum; DonorOrg.ContactEmail = model.ContactEmail; DonorOrg.Thanked = model.Thanked; DonorOrg.StreetAddress = model.StreetAddress; DonorOrg.City = model.City; DonorOrg.AreaCode = model.AreaCode; db.SaveChanges(); } TempData["js"] = "myUpdateSuccess()"; return(RedirectToAction("Index", "DonorOrg")); } return(View("Index", model)); }
// GET: VehicleDetails public ActionResult Index(string vehicleID) { Models.Vehicle myModel = new Models.Vehicle(); CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (vehicleID != null) { var intVehicleID = Int32.Parse(vehicleID); var myVehicle = db.Vehicles.Where(i => i.VehicleID == intVehicleID).FirstOrDefault(); var myTypeID = db.Vehicle_Type.Where(i => i.TypeID == myVehicle.TypeID).FirstOrDefault(); myModel.VehicleID = myVehicle.VehicleID; myModel.Brand = myVehicle.Brand; myModel.Model = myVehicle.Model; myModel.NumberPlate = myVehicle.NumberPlate; myModel.DateofPurchase = myVehicle.DateOfPurchase; myModel.DateofLastRepair = myVehicle.DateofLastRepair; myModel.DateofLicencePurchase = myVehicle.DateofLicencePurchase; myModel.LicenseExpireDate = myVehicle.LicenseExpireDate; myModel.ServiceIntervalInMonths = myVehicle.ServiceIntervalInMonths; myModel.ServiceIntervalInKMs = myVehicle.ServiceIntervalInKMs; myModel.TypeID = myTypeID.TypeID; myModel.TypeName = db.Vehicle_Type.Where(i => i.TypeID == myTypeID.TypeID).FirstOrDefault().Name; } myModel.VehicleTypes = db.Vehicle_Type.ToList(); return(View(myModel)); }
// GET: AddEquipment public ActionResult Index() { var db = new CodeFirst.CodeFirst(); var equipments = new Models.Equipment(); var users = db.Users .AsEnumerable() .Select(u => new SelectListItem { Value = u.UserID.ToString(), Text = u.FirstName + " " + u.LastName }).ToList(); equipments.Users = users; equipments.EquipmentTypes = db.Equipment_Type.ToList(); return(View(equipments)); /*var equipmentFromType = (Models.Equipment)TempData["EquipmentModel"]; * if (equipmentFromType != null) * { * equipmentFromType.EquipmentTypes = db.Equipment_Type.ToList(); * return View(equipmentFromType); * } * else * { * var equipments = new Models.Equipment(); * equipments.EquipmentTypes = db.Equipment_Type.ToList(); * return View(equipments); * }*/ }
public ActionResult DoRestore() { string dbPath = Server.MapPath("~/App_Data/DBBackup.bak"); using (var db = new CodeFirst.CodeFirst()) { /* var cmd = String.Format("restore DATABASE {0} from DISK='{1}';" * , "CompudataSQL", dbPath); // ? * db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, cmd);*/ //--------------------------------------------------------- //var cmd = String.Format("restore DATABASE {0} from DISK='{1}';" // , "FarmDb", dbPath); var cmd = String.Format("USE master restore DATABASE CompudataSQL from DISK='{0}' WITH REPLACE;", dbPath); //var cmd1 = String.Format("alter database FarmDb set with rollback immediate"); //var cmd2 = String.Format("USE master alter database FarmDb set online"); var cmd3 = String.Format("ALTER DATABASE CompudataSQL SET SINGLE_USER WITH ROLLBACK IMMEDIATE "); var cmd4 = String.Format("ALTER DATABASE CompudataSQL SET MULTI_USER"); db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, cmd3); db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, cmd); db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, cmd4); } return(RedirectToAction("Index", "MainMenu")); // return View(); }
// GET: FunderPersonDetails public ActionResult Index(string funderPersonID) { Models.Funder_Person myModel = new Models.Funder_Person(); CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (funderPersonID != null) { var intFunderPersonID = Int32.Parse(funderPersonID); var myFunderPerson = db.Funder_Person.Where(i => i.FunderPersonID == intFunderPersonID).FirstOrDefault(); var mytypeID = db.Funder_Type.Where(i => i.TypeID == myFunderPerson.TypeID).FirstOrDefault(); var myProjectID = db.Projects.Where(i => i.ProjectID == myFunderPerson.ProjectID).FirstOrDefault(); myModel.FunderPersonID = myFunderPerson.FunderPersonID; myModel.FirstName = myFunderPerson.FirstName; myModel.MiddleName = myFunderPerson.MiddleName; myModel.LastName = myFunderPerson.LastName; myModel.Initials = myFunderPerson.Initials; myModel.CellNum = myFunderPerson.CellNum; myModel.PersonalEmail = myFunderPerson.PersonalEmail; myModel.Bank = myFunderPerson.Bank; myModel.AccountNumber = myFunderPerson.AccountNumber; myModel.BranchCode = myFunderPerson.BranchCode; myModel.StreetAddress = myFunderPerson.StreetAddress; myModel.City = myFunderPerson.City; myModel.AreaCode = myFunderPerson.AreaCode; myModel.Thanked = myFunderPerson.Thanked; myModel.ProjectName = myProjectID != null ? myProjectID.ProjectName : "None"; myModel.Name = mytypeID.Name; } return(View(myModel)); }
public ActionResult Modify([Bind(Prefix = "")] Models.Supplier model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { var Supplier = db.Suppliers.Where(v => v.SupplierID == model.SupplierID).SingleOrDefault(); if (Supplier != null) { Supplier.SupplierID = model.SupplierID; Supplier.Name = model.Name; Supplier.VATNumber = model.VATNumber; Supplier.EmailAddress = model.EmailAddress; Supplier.ContactNumber = model.ContactNumber; Supplier.Bank = model.Bank; Supplier.AccountNumber = model.AccountNumber; Supplier.BranchCode = model.BranchCode; Supplier.POAddress = model.POAddress; Supplier.POCity = model.POCity; Supplier.POAreaCode = model.POAreaCode; db.SaveChanges(); } TempData["js"] = "myUpdateSuccess()"; return(RedirectToAction("Index", "Supplier")); } return(View("Index", model)); }
// GET: AddSoftwareLicenses public ActionResult Index() { var db = new CodeFirst.CodeFirst(); var SoftwareLic = new Models.SoftwareLicenses(); return(View(SoftwareLic)); }
public JsonResult GetEvents() { using (CodeFirst.CodeFirst db = new CodeFirst.CodeFirst()) { db.Configuration.LazyLoadingEnabled = false; var events = db.Venue_Booking_Line.ToList(); var newData = (from e in events join b in db.Buildings.ToList() on e.BuildingID equals b.BuildingID join v in db.Venues.ToList() on e.VenueID equals v.VenueID join p in db.Projects.ToList() on e.ProjectID equals p.ProjectID join u in db.Users.ToList() on e.UserID equals u.UserID select new { People = e.NumberofPeople, DateBooked = e.DateBooked.ToString("MM/dd/yyyy"), StartTime = e.StartTime, EndTime = e.EndTime, UserName = u.FirstName + " " + u.LastName, Venue = v.Name, Building = b.Name, ProjectName = p.ProjectName }) .ToList(); var myResult = new JsonResult(); myResult = new JsonResult { Data = newData, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; db.Configuration.LazyLoadingEnabled = false; return(Json(newData, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create([Bind(Prefix = "")] Models.SoftwareLicenses model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { if (db.Software_Licenses.Count() > 0) { var item = db.Software_Licenses.OrderByDescending(a => a.LicenceID).FirstOrDefault(); db.Software_Licenses.Add(new CodeFirst.Software_Licenses { LicenceID = item.LicenceID + 1, SoftwareName = model.SoftwareName, ActivationPeriodInMonths = model.ActivationPeriodInMonths }); } else { db.Software_Licenses.Add(new CodeFirst.Software_Licenses { LicenceID = 1, SoftwareName = model.SoftwareName, ActivationPeriodInMonths = model.ActivationPeriodInMonths }); } db.SaveChanges(); model.JavaScriptToRun = "mySuccess()"; TempData["model"] = model; return(RedirectToAction("Index", "SoftwareLicenses")); } return(View("Index", model)); }
public ActionResult Create([Bind(Prefix = "")] Models.QuantityType model) { if (ModelState.IsValid) { var db = new CodeFirst.CodeFirst(); if (db.Quantity_Type.Count() > 0) { var item = db.Quantity_Type.OrderByDescending(a => a.QuantityTypeID).FirstOrDefault(); db.Quantity_Type.Add(new CodeFirst.Quantity_Type { QuantityTypeID = item.QuantityTypeID + 1, Description = model.Description }); } else { db.Quantity_Type.Add(new CodeFirst.Quantity_Type { QuantityTypeID = 1, Description = model.Description }); } db.SaveChanges(); model.JavaScriptToRun = "mySuccess()"; TempData["model"] = model; return(RedirectToAction("Index", "QuantityType")); } return(View("Index", model)); }
// GET: ModifyDonation public ActionResult Index(string donationID) { Models.Donation myModel = new Models.Donation(); CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (donationID != null) { var intDonationID = Int32.Parse(donationID); var myDonation = db.Donations.Where(i => i.DonationID == intDonationID).FirstOrDefault(); myModel.DonationID = myDonation.DonationID; myModel.DateDate = myDonation.DateDate; myModel.DonorPID = myDonation.DonorPID; myModel.DonorOrgID = myDonation.DonorOrgID; myModel.DonorPeople = db.Donor_Person.AsEnumerable().Select(d => new SelectListItem { Value = d.DonorPID.ToString(), Text = d.FirstName + " " + d.SecondName }).ToList(); myModel.DonorOrgs = db.Donor_Org.AsEnumerable().Select(o => new SelectListItem { Value = o.DonorOrgID.ToString(), Text = o.OrgName }).ToList(); myModel.DonationTypes = db.Donation_Type.ToList(); myModel.Lines = myDonation.Donation_Line.ToList(); } return(View(myModel)); }
// GET: AddRefreshment public ActionResult Index() { var db = new CodeFirst.CodeFirst(); var refreshment = new Models.Refreshment(); return(View(refreshment)); }
// GET: EquipmentDetails public ActionResult Index(string equipmentID) { Models.Equipment myModel = new Models.Equipment(); CodeFirst.CodeFirst db = new CodeFirst.CodeFirst(); if (equipmentID != null) { var intEquipmentID = Int32.Parse(equipmentID); var myEquipment = db.Equipments.Where(i => i.EquipmentID == intEquipmentID).FirstOrDefault(); var myUser = db.Users.Where(u => u.UserID == myEquipment.UserID).FirstOrDefault(); var myType = db.Equipment_Type.Where(t => t.TypeID == myEquipment.TypeID).FirstOrDefault(); myModel.EquipmentID = myEquipment.EquipmentID; myModel.ManufacturerName = myEquipment.ManufacturerName; myModel.ModelNumber = myEquipment.ModelNumber; myModel.DatePurchased = myEquipment.DatePurchased; myModel.ServiceIntervalMonths = myEquipment.ServiceIntervalMonths; myModel.Status = myEquipment.Status; myModel.UserID = myEquipment.UserID; myModel.UserName = myUser != null ? myUser.FirstName + " " + myUser.LastName : "Not Assigned to User"; myModel.TypeID = myEquipment.TypeID; myModel.TypeName = myType.TypeName; } return(View(myModel)); }
public ActionResult Modify([Bind(Prefix = "")] Models.Funder_Org model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { var myFunderOrg = db.Funder_Org.Where(v => v.FunderOrgID == model.FunderOrgID).SingleOrDefault(); if (myFunderOrg != null) { myFunderOrg.FunderOrgID = model.FunderOrgID; myFunderOrg.OrgName = model.OrgName; myFunderOrg.ContactNumber = model.ContactNumber; myFunderOrg.EmailAddress = model.EmailAddress; myFunderOrg.Bank = model.Bank; myFunderOrg.AccountNumber = model.AccountNumber; myFunderOrg.BranchCode = model.BranchCode; myFunderOrg.StreetAddress = model.StreetAddress; myFunderOrg.City = model.City; myFunderOrg.AreaCode = model.AreaCode; myFunderOrg.Thanked = model.Thanked; myFunderOrg.TypeID = model.TypeID; myFunderOrg.ProjectID = model.ProjectID; db.SaveChanges(); } TempData["js"] = "myUpdateSuccess()"; return(RedirectToAction("Index", "FunderOrg")); } return(View("Index", model)); }
public ActionResult Modify([Bind(Prefix = "")] Models.SoftwareLicensesLine model) { var db = new CodeFirst.CodeFirst(); if (ModelState.IsValid) { var line = db.Software_Licenses_Line.Where(v => v.LineID == model.LineID).SingleOrDefault(); if (line != null) { line.EquipmentID = model.EquipmentID; line.LicenceID = model.LicenceID; line.LastActivatedDate = model.LastActivatedDate; line.Activated = model.Activated; db.SaveChanges(); } TempData["js"] = "myUpdateSuccess()"; return(RedirectToAction("Index", "EquipmentSoftwareLicenses")); } model.Softwares = db.Software_Licenses.ToList(); model.Equipments = db.Equipments.AsEnumerable().Select(e => new SelectListItem { Value = e.EquipmentID.ToString(), Text = e.ManufacturerName + " " + e.ModelNumber }).ToList(); return(View("Index", model)); }