public async Task <ActionResult> DeleteConfirmed(int id) { SPP sPP = await db.SPPs.FindAsync(id); string comment = $"Id: {sPP.Id}"; comment += $" Count: {sPP.Count.ToString()}"; comment += $" Power: {sPP.Power.ToString()}"; comment += $" Cost: {sPP.Cost}"; comment += $" Startup: {sPP.Startup.ToString()}"; comment += $" Link: {sPP.Link}"; comment += $" Customer: {sPP.Customer}"; comment += $" Investor: {sPP.Investor}"; comment += $" Executor: {sPP.Executor}"; comment += $" CapacityFactor: {sPP.CapacityFactor.ToString()}"; comment += $" SPPStatusId: {sPP.SPPStatusId.ToString()}"; comment += $" SPPPurposeId: {sPP.SPPPurposeId.ToString()}"; comment += $" PanelOrientationId: {sPP.PanelOrientationId.ToString()}"; comment += $" Coordinates: {sPP.Coordinates}"; SystemLog.New("SPPCreate", comment, null, false); db.SPPs.Remove(sPP); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Count,Power,Cost,Startup,Link,Customer,Investor,Executor,Name,CapacityFactor,SPPStatusId,SPPPurposeId,PanelOrientationId,Coordinates")] SPP sPP, HttpPostedFileBase Photo) { if (ModelState.IsValid) { SPP sPPdb = null; using (var dblocal = new NpgsqlContext()) { sPPdb = dblocal.SPPs.Find(sPP.Id); } sPP.Photo = sPPdb.Photo; if (Photo != null && Photo.ContentLength > 0) { sPP.Photo = null; MemoryStream target = new MemoryStream(); Photo.InputStream.CopyTo(target); sPP.Photo = target.ToArray(); } string comment = $"Id: {sPPdb.Id}"; comment += $" Count: {sPPdb.Count.ToString()}"; comment += $" Power: {sPPdb.Power.ToString()}"; comment += $" Cost: {sPPdb.Cost}"; comment += $" Startup: {sPPdb.Startup.ToString()}"; comment += $" Link: {sPPdb.Link}"; comment += $" Customer: {sPPdb.Customer}"; comment += $" Investor: {sPPdb.Investor}"; comment += $" Executor: {sPPdb.Executor}"; comment += $" CapacityFactor: {sPPdb.CapacityFactor.ToString()}"; comment += $" SPPStatusId: {sPPdb.SPPStatusId.ToString()}"; comment += $" SPPPurposeId: {sPPdb.SPPPurposeId.ToString()}"; comment += $" PanelOrientationId: {sPPdb.PanelOrientationId.ToString()}"; comment += $" Coordinates: {sPPdb.Coordinates}"; comment += $" -> Count: {sPP.Count.ToString()}"; comment += $" Power: {sPP.Power.ToString()}"; comment += $" Cost: {sPP.Cost}"; comment += $" Startup: {sPP.Startup.ToString()}"; comment += $" Link: {sPP.Link}"; comment += $" Customer: {sPP.Customer}"; comment += $" Investor: {sPP.Investor}"; comment += $" Executor: {sPP.Executor}"; comment += $" CapacityFactor: {sPP.CapacityFactor.ToString()}"; comment += $" SPPStatusId: {sPP.SPPStatusId.ToString()}"; comment += $" SPPPurposeId: {sPP.SPPPurposeId.ToString()}"; comment += $" PanelOrientationId: {sPP.PanelOrientationId.ToString()}"; comment += $" Coordinates: {sPP.Coordinates}"; SystemLog.New("SPPEdit", comment, null, false); db.Entry(sPP).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PanelOrientationId = new SelectList(db.PanelOrientations, "Id", "Name", sPP.PanelOrientationId); ViewBag.SPPPurposeId = new SelectList(db.SPPPurposes, "Id", "Name", sPP.SPPPurposeId); ViewBag.SPPStatusId = new SelectList(db.SPPStatus, "Id", "Name", sPP.SPPStatusId); return(View(sPP)); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SPP sPP = await db.SPPs.FindAsync(id); if (sPP == null) { return(HttpNotFound()); } ViewBag.PanelOrientationId = new SelectList(db.PanelOrientations, "Id", "Name", sPP.PanelOrientationId); ViewBag.SPPPurposeId = new SelectList(db.SPPPurposes, "Id", "Name", sPP.SPPPurposeId); ViewBag.SPPStatusId = new SelectList(db.SPPStatus, "Id", "Name", sPP.SPPStatusId); return(View(sPP)); }
public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SPP sPP = await db.SPPs .Where(s => s.Id == id) .Include(s => s.PanelOrientation) .Include(s => s.SPPPurpose) .Include(s => s.SPPStatus) .FirstOrDefaultAsync(); if (sPP == null) { return(HttpNotFound()); } return(View(sPP)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Count,Power,Cost,Startup,Link,Customer,Investor,Executor,Name,CapacityFactor,SPPStatusId,SPPPurposeId,PanelOrientationId,Coordinates")] SPP sPP, HttpPostedFileBase Photo) { if (ModelState.IsValid) { if (Photo != null) { MemoryStream target = new MemoryStream(); Photo.InputStream.CopyTo(target); sPP.Photo = target.ToArray(); } db.SPPs.Add(sPP); await db.SaveChangesAsync(); string comment = $"Id: {sPP.Id}"; comment += $" Count: {sPP.Count.ToString()}"; comment += $" Power: {sPP.Power.ToString()}"; comment += $" Cost: {sPP.Cost}"; comment += $" Startup: {sPP.Startup.ToString()}"; comment += $" Link: {sPP.Link}"; comment += $" Customer: {sPP.Customer}"; comment += $" Investor: {sPP.Investor}"; comment += $" Executor: {sPP.Executor}"; comment += $" CapacityFactor: {sPP.CapacityFactor.ToString()}"; comment += $" SPPStatusId: {sPP.SPPStatusId.ToString()}"; comment += $" SPPPurposeId: {sPP.SPPPurposeId.ToString()}"; comment += $" PanelOrientationId: {sPP.PanelOrientationId.ToString()}"; comment += $" Coordinates: {sPP.Coordinates}"; SystemLog.New("SPPCreate", comment, null, false); return(RedirectToAction("Index")); } ViewBag.PanelOrientationId = new SelectList(db.PanelOrientations, "Id", "Name", sPP.PanelOrientationId); ViewBag.SPPPurposeId = new SelectList(db.SPPPurposes, "Id", "Name", sPP.SPPPurposeId); ViewBag.SPPStatusId = new SelectList(db.SPPStatus, "Id", "Name", sPP.SPPStatusId); return(View(sPP)); }