public ActionResult CreateOrEditCorset(Corset Corset) { if (ModelState.IsValid) { if (Corset.Id == 0) { db.Corsets.Add(Corset); } else { var CorsetFromDb = db.Corsets.First(s => s.Id == Corset.Id); CorsetFromDb.CorsetType_Id = Corset.CorsetType_Id; CorsetFromDb.Start = Corset.Start; CorsetFromDb.End = Corset.End; CorsetFromDb.Comment = Corset.Comment; } db.SaveChanges(User.Identity.Name); ViewBag.ParticipantId = Corset.Participant_Id; var participant = db.Participants .Include(a => a.Corsets.Select(s => s.CorsetType)) .First(a => a.Id == Corset.Participant_Id); ViewBag.CorsetType_Id = new SelectList(db.CorsetTypes, "Id", Session["Language"].ToString().ToLower() == "en" ? "Name" : "NameFr"); return(Json(new { success = true, html = this.RenderPartialViewToString("_ListCorsets", participant) })); } ViewBag.CorsetType_Id = new SelectList(db.CorsetTypes, "Id", "Name", Corset.CorsetType_Id); return(Json(new { success = false, message = "form is invalid" })); }
public void Creation() { var TestObject = new Corset(new ICompressor[] { new DeflateCompressor(), new GZipCompressor() }); Assert.NotNull(TestObject); Assert.Equal(2, TestObject.Compressors.Count); }
public void Decompress() { var TestObject = new Corset(new ICompressor[] { new DeflateCompressor(), new GZipCompressor() }); string Data = "This is a bit of data that I want to compress"; Assert.Equal("This is a bit of data that I want to compress", TestObject.Decompress(TestObject.Compress(Data.ToByteArray(), CompressorType.Deflate), CompressorType.Deflate).ToString(null)); }
public void Compress() { var TestObject = new Corset(new ICompressor[] { new DeflateCompressor(), new GZipCompressor() }); string Data = "This is a bit of data that I want to compress"; Assert.Equal("CsnILFYAokSFpMwShfw0hZTEkkSFkozEEgVPhfLEvBKFknyF5PzcgqLU4mIAAAAA//8=", Convert.ToBase64String(TestObject.Compress(Data.ToByteArray(), CompressorType.Deflate))); }
public ActionResult DeleteConfirmed(int id) { Corset corset = db.Corsets.Find(id); db.Corsets.Remove(corset); db.SaveChanges(User.Identity.Name); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Start,End,Comment,Participant_Id,CorsetType_Id")] Corset corset) { if (ModelState.IsValid) { db.Entry(corset).State = EntityState.Modified; db.SaveChanges(User.Identity.Name); return(RedirectToAction("Index")); } ViewBag.CorsetType_Id = new SelectList(db.CorsetTypes, "Id", "Name", corset.CorsetType_Id); ViewBag.Participant_Id = new SelectList(db.Participants, "Id", "FirstName", corset.Participant_Id); return(View(corset)); }
// GET: /Corset/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Corset corset = db.Corsets.Find(id); if (corset == null) { return(HttpNotFound()); } return(View(corset)); }
// GET: /Corset/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Corset corset = db.Corsets.Find(id); if (corset == null) { return(HttpNotFound()); } ViewBag.CorsetType_Id = new SelectList(db.CorsetTypes, "Id", "Name", corset.CorsetType_Id); ViewBag.Participant_Id = new SelectList(db.Participants, "Id", "FirstName", corset.Participant_Id); return(View(corset)); }