public IHttpActionResult CreatePlc(PlcDto plcDto) { if (!ModelState.IsValid) { return(BadRequest()); } var plc = Mapper.Map <PlcDto, Plc>(plcDto); _context.Plcs.Add(plc); _context.SaveChanges(); plcDto.Id = plc.Id; return(Created(new Uri(Request.RequestUri + "/" + plc.Id), plcDto)); }
public IHttpActionResult UpdatePlc(PlcDto plcDto) { if (!ModelState.IsValid) { return(BadRequest()); } var plcInDb = _context.Plcs.SingleOrDefault(p => p.Id == plcDto.Id); if (plcInDb == null) { return(NotFound()); } Mapper.Map(plcDto, plcInDb); _context.SaveChanges(); return(Ok()); }