コード例 #1
0
        public Response <Equipment> Post([FromBody] EquipmentModel equipment)
        {
            var model    = _mapper.Map <Equipment>(equipment);
            var response = _equipmentService.Add(model);

            return(response);
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "SerialNumber,Name,Picture,NextControlDate")]
                                   EquipmentModel EquipmentModel)
        {
            if (ModelState.IsValid)
            {
                var picture = new byte[0];
                if (EquipmentModel.Picture != null)
                {
                    var target = new MemoryStream();
                    EquipmentModel.Picture.InputStream.CopyTo(target);
                    picture = target.ToArray();
                }

                var equipmentVO = new EquipmentVO
                {
                    Name            = EquipmentModel.Name,
                    NextControlDate = EquipmentModel.NextControlDate,
                    Picture         = picture,
                    SerialNumber    = EquipmentModel.SerialNumber
                };
                try
                {
                    _equipmentService.Add(equipmentVO);
                }
                catch (EquipmentExistException)

                {
                    return(RedirectToAction("Unique"));
                }

                return(RedirectToAction("Index"));
            }

            return(View(EquipmentModel));
        }
コード例 #3
0
        public ActionResult AddEquipment(EquipmentDto dto, int rid)
        {
            dto.Room_id = rid;


            int i = _equipmentService.Add(dto);

            ViewBag.Rid = rid;
            return(RedirectToAction("AddEquipment", new { rid = rid }));
        }
コード例 #4
0
        public IActionResult Add(Equipment equipment)
        {
            var result = _equipmentService.Add(equipment);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
コード例 #5
0
        public async Task <IActionResult> Add(Equipment equipment)
        {
            var result = await _equipmentService.Add(equipment);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
コード例 #6
0
        public async Task <IActionResult> Create(EquipmentDTO equip)
        {
            if (ModelState.IsValid)
            {
                await _equipSvc.Add(equip);

                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(Index)));
        }