public async Task Post() { OrderTypeViewModel VM = GenerateTestModel(); var response = await this.Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json")); Assert.Equal(HttpStatusCode.Created, response.StatusCode); }
public bool Change(OrderTypeViewModel entity) { using (var repository = _sourceFactory.CreateRepository <Entity.OrderType, int>()) { return(repository.Change(new OrderType(entity.OrderTypeId, entity.OrderTypeName))); } }
public OrderTypeViewModel MapToViewModel(OrderType model) { OrderTypeViewModel viewModel = new OrderTypeViewModel(); PropertyCopier <OrderType, OrderTypeViewModel> .Copy(model, viewModel); return(viewModel); }
public OrderType MapToModel(OrderTypeViewModel viewModel) { OrderType model = new OrderType(); PropertyCopier <OrderTypeViewModel, OrderType> .Copy(viewModel, model); return(model); }
public async Task Delete() { OrderType OrderType = await DataUtil.GetTestDataAsync(); OrderTypeViewModel VM = Service.MapToViewModel(OrderType); var response = await this.Client.DeleteAsync(string.Concat(URI, "/", VM.Id)); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); }
public async Task Update() { OrderType OrderType = await DataUtil.GetTestDataAsync(); OrderTypeViewModel VM = Service.MapToViewModel(OrderType); var response = await this.Client.PutAsync(string.Concat(URI, "/", VM.Id), new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json")); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); }
// GET: OrderTypes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderTypeViewModel orderType = Mapper.Map <OrderTypeViewModel>(orderTypeService.Get(id.Value)); if (orderType == null) { return(HttpNotFound()); } return(View(orderType)); }
public ActionResult Delete(int Id) { OrderTypeViewModel foundOrderType = _orderTypeViewService.ViewAll().FirstOrDefault(c => c.Id == Id); if (foundOrderType != null) { _orderTypeModifyService.Delete(foundOrderType.Id); TempData["message"] = string.Format("Order type was deleted"); return(RedirectToAction("Index")); } else { TempData["message"] = string.Format("Order type was not found"); } return(RedirectToAction("Index")); }
public ActionResult Edit(OrderTypeViewModel orderType) { if (ModelState.IsValid) { if (orderTypes.Any(c => c.OrderTypeId == orderType.OrderTypeId)) { _db.OrderType.Change(orderType); TempData["message"] = string.Format("Order type \"{0}\"uploaded", orderType.OrderTypeName); } else { _db.OrderType.Add(orderType); TempData["message"] = string.Format("Order type\"{0}\"added", orderType.OrderTypeName); } return(RedirectToAction("Index")); } else { return(View(orderType)); } }
public ActionResult Edit(OrderTypeViewModel orderType) { if (ModelState.IsValid) { OrderTypeViewModel foundOrderType = _orderTypeViewService.ViewAll().FirstOrDefault(c => c.Id == orderType.Id); if (foundOrderType != null) { _orderTypeModifyService.Update(foundOrderType.Id, new OrderTypeModifyModel(orderType.OrderTypeName)); TempData["message"] = string.Format("Order type \"{0}\"uploaded", orderType.OrderTypeName); } else { _orderTypeModifyService.Add(new OrderTypeModifyModel(orderType.OrderTypeName)); TempData["message"] = string.Format("Order type\"{0}\"added", orderType.OrderTypeName); } return(RedirectToAction("Index")); } else { return(View(orderType)); } }
public ViewResult Edit(int?OrderTypeId) { OrderTypeViewModel orderType = orderTypes.FirstOrDefault(c => c.OrderTypeId == OrderTypeId); return(View(orderType)); }
public MaterialsRequestNoteViewModel MapToViewModel(MaterialsRequestNote model) { MaterialsRequestNoteViewModel viewModel = new MaterialsRequestNoteViewModel(); PropertyCopier <MaterialsRequestNote, MaterialsRequestNoteViewModel> .Copy(model, viewModel); UnitViewModel Unit = new UnitViewModel() { _id = model.UnitId, code = model.UnitCode, name = model.UnitName }; viewModel.Code = model.Code; viewModel.Unit = Unit; viewModel.RequestType = model.RequestType; viewModel.Remark = model.Remark; viewModel.MaterialsRequestNote_Items = new List <MaterialsRequestNote_ItemViewModel>(); if (model.MaterialsRequestNote_Items != null) { foreach (MaterialsRequestNote_Item materialsRequestNote_Item in model.MaterialsRequestNote_Items) { MaterialsRequestNote_ItemViewModel materialsRequestNote_ItemViewModel = new MaterialsRequestNote_ItemViewModel(); PropertyCopier <MaterialsRequestNote_Item, MaterialsRequestNote_ItemViewModel> .Copy(materialsRequestNote_Item, materialsRequestNote_ItemViewModel); OrderTypeViewModel OrderType = new OrderTypeViewModel() { _id = materialsRequestNote_Item.OrderTypeId, code = materialsRequestNote_Item.OrderTypeCode, name = materialsRequestNote_Item.OrderTypeName }; ProductionOrderViewModel ProductionOrder = new ProductionOrderViewModel() { _id = materialsRequestNote_Item.ProductionOrderId, orderNo = materialsRequestNote_Item.ProductionOrderNo, orderQuantity = materialsRequestNote_Item.OrderQuantity, isCompleted = materialsRequestNote_Item.ProductionOrderIsCompleted, distributedQuantity = materialsRequestNote_Item.DistributedLength, orderType = OrderType }; materialsRequestNote_ItemViewModel.ProductionOrder = ProductionOrder; ProductViewModel Product = new ProductViewModel() { _id = materialsRequestNote_Item.ProductId, code = materialsRequestNote_Item.ProductCode, name = materialsRequestNote_Item.ProductName }; materialsRequestNote_ItemViewModel.Product = Product; materialsRequestNote_ItemViewModel.Length = materialsRequestNote_Item.Length; materialsRequestNote_ItemViewModel.DistributedLength = materialsRequestNote_Item.DistributedLength; viewModel.MaterialsRequestNote_Items.Add(materialsRequestNote_ItemViewModel); } } return(viewModel); }
public ViewResult Edit(int?Id) { OrderTypeViewModel orderType = Id != null?_orderTypeViewService.ViewSingle(Convert.ToInt32(Id.ToString())) : new OrderTypeViewModel(); return(View(orderType)); }