public async Task TestGetNotFoundEquipmentType() { try { await CrudClient.GetElementById("1"); } catch (System.Net.Http.HttpRequestException exception) { Assert.Contains("404", exception.Message); return; } Assert.False(true, "response must be not found"); }
public async Task <ActionResult> Edit([Bind(Include = "Client,ClientLanguage,Language")] CrudClient cc) { if (ModelState.IsValid) { cc.Client.LastEditTime = DateTime.Now; cc.Client.LastEditUser = User.Identity.GetUserId(); db.Entry(cc.Client).State = EntityState.Modified; await db.SaveChangesAsync(); foreach (var cl in cc.ClientLanguage) { db.Entry(cl.Value).State = EntityState.Modified; } await db.SaveChangesAsync(); return(RedirectToAction("Edit", "Option", new { area = "Manage" })); } return(View(cc)); }
public async Task TestUpdateAndGetEquipmentType() { var equipment = new EquipmentType() { Id = "2", Name = "Фрезеровальный станок" }; await EquipmentCRUDClient.CreateAsync(equipment); var supplier = new Supplier() { Id = "2", Name = "НВС-строй", Address = "Васильева 17" }; await SupplierCRUDClient.CreateAsync(supplier); var expected = new Supply() { Id = "1", Count = 5, DeliveryDate = DateTime.Now, EquipmentTypeId = "2", SupplierId = "2" }; await CrudClient.CreateAsync(expected); expected.DeliveryDate = new DateTime(2017, 1, 1); await CrudClient.UpdateAsync(expected); var actual = await CrudClient.GetFirstElement(); Assert.Equal(expected, actual); await CrudClient.DeleteElement("1"); await EquipmentCRUDClient.DeleteElement("2"); await SupplierCRUDClient.DeleteElement("2"); }
// GET: Manage/Client/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var client = await db.Client.FindAsync(id); if (client == null) { return(HttpNotFound()); } var clientlanguage = await(from cl in db.ClientLanguage where cl.ClientId == client.Id select cl).ToListAsync(); var cld = new Dictionary <string, ClientLanguage>() { }; foreach (var cl in clientlanguage) { var langcode = await(from lc in db.Language where lc.Id == cl.LanguageId select lc).FirstOrDefaultAsync(); cld.Add(langcode.Code, cl); } var cc = new CrudClient() { Client = client, ClientLanguage = cld }; return(View(cc)); }
// GET: Manage/Client/Create public ActionResult Create() { var model = new CrudClient(); return(View(model)); }