コード例 #1
0
        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);
        }
コード例 #2
0
 public bool Change(OrderTypeViewModel entity)
 {
     using (var repository = _sourceFactory.CreateRepository <Entity.OrderType, int>())
     {
         return(repository.Change(new OrderType(entity.OrderTypeId, entity.OrderTypeName)));
     }
 }
コード例 #3
0
        public OrderTypeViewModel MapToViewModel(OrderType model)
        {
            OrderTypeViewModel viewModel = new OrderTypeViewModel();

            PropertyCopier <OrderType, OrderTypeViewModel> .Copy(model, viewModel);

            return(viewModel);
        }
コード例 #4
0
        public OrderType MapToModel(OrderTypeViewModel viewModel)
        {
            OrderType model = new OrderType();

            PropertyCopier <OrderTypeViewModel, OrderType> .Copy(viewModel, model);

            return(model);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        // 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));
        }
コード例 #8
0
        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"));
        }
コード例 #9
0
 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));
     }
 }
コード例 #10
0
        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));
            }
        }
コード例 #11
0
        public ViewResult Edit(int?OrderTypeId)
        {
            OrderTypeViewModel orderType = orderTypes.FirstOrDefault(c => c.OrderTypeId == OrderTypeId);

            return(View(orderType));
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public ViewResult Edit(int?Id)
        {
            OrderTypeViewModel orderType = Id != null?_orderTypeViewService.ViewSingle(Convert.ToInt32(Id.ToString())) : new OrderTypeViewModel();

            return(View(orderType));
        }