public async Task<ActionResult> ReturnDeletedProject(string id) { if(string.IsNullOrEmpty(id)) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var dele = await db.DeletedProject.Where(c => c.Id == id).FirstOrDefaultAsync(); var pro = new ProjectModel() { Id = dele.Id, additionalInfo = dele.additionalInfo, CategoryID = dele.CategoryID, descProject = dele.descProject, money = dele.money, moneyRaised = dele.moneyRaised, moneyWithCommission = dele.moneyWithCommission, nameProject = dele.nameProject, numberOfDonations = dele.numberOfDonations, tagsProject = dele.tagsProject, suspended = true }; db.DeletedProject.Remove(dele); db.Project.Add(pro); await db.SaveChangesAsync(); return RedirectToAction("DeletedProjects"); }
public async Task<ActionResult> ProjectEdit(ProjectModel kreiran) { if(ModelState.IsValid) { db.Entry(kreiran).State = EntityState.Modified; await db.SaveChangesAsync(); TempData["message"] = "Project successfully saved!"; return RedirectToAction("ProjectIndex"); } ViewBag.CategoryID = new SelectList(db.Category.ToList(), "Id", "nameCategory", kreiran.CategoryID); return View(kreiran); }
public async Task<ActionResult> ProjectDelete(ProjectModel p) { var pro = await db.Project.Where(c => c.Id == p.Id).FirstOrDefaultAsync(); var dele = new ProjectDeleteModel() { Id = pro.Id, additionalInfo = pro.additionalInfo, CategoryID = pro.CategoryID, descProject = pro.descProject, money = pro.money, moneyRaised = pro.moneyRaised, moneyWithCommission = pro.moneyWithCommission, nameProject = pro.nameProject, numberOfDonations = pro.numberOfDonations, tagsProject = pro.tagsProject, suspended = true }; db.DeletedProject.Add(dele); db.Project.Remove(pro); await db.SaveChangesAsync(); TempData["success_msg_proj"] = "Project successfully deleted!"; return RedirectToAction("ProjectIndex"); }
public async Task<ActionResult> ProjectCreate(ProjectModel modelProj) { modelProj.Id = Guid.NewGuid().ToString(); //modelProj.categoryMod = db.Category.Where(c => c.Id == categoryMod).FirstOrDefault(); //modelProj.moneyWithCommission = (modelProj.money / 100) * 104; //modelProj.moneyRaised = 0; //modelProj.numberOfDonations = 0; if(ModelState.IsValid) { db.Project.Add(modelProj); await db.SaveChangesAsync(); return RedirectToAction("ProjectIndex"); } ViewBag.CategoryID = new SelectList(db.Category.ToList(), "Id", "nameCategory", modelProj.CategoryID); return View(modelProj); }