public Response <Equipment> Post([FromBody] EquipmentModel equipment) { var model = _mapper.Map <Equipment>(equipment); var response = _equipmentService.Add(model); return(response); }
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)); }
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 })); }
public IActionResult Add(Equipment equipment) { var result = _equipmentService.Add(equipment); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> Add(Equipment equipment) { var result = await _equipmentService.Add(equipment); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> Create(EquipmentDTO equip) { if (ModelState.IsValid) { await _equipSvc.Add(equip); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); }