public async Task <ActionResult <ViewOtgulRecord> > PutOtgulRecord(int id, [FromBody] ViewOtgulRecord viewOtgulRecord) { OtgulRecord tmpOtgulRecord = _otgulRecordService.GetOtgulRecordFromId(viewOtgulRecord.Id); if (tmpOtgulRecord != null) { _otgulRecordService.UpdateOtgulRecord(_mapper.Map(viewOtgulRecord)); return(_mapper.Map(_otgulRecordService.GetOtgulRecordFromId(viewOtgulRecord.Id))); } else { return(NotFound()); } }
public OtgulRecord Map(ViewOtgulRecord viewOtgulRecord) { return(new OtgulRecord { Id = viewOtgulRecord.Id, User = Map(viewOtgulRecord.User), Action = viewOtgulRecord.Action, MinutCount = viewOtgulRecord.MinutCount, Initiator = Map(viewOtgulRecord.Initiator), Date = viewOtgulRecord.Date, Guide = viewOtgulRecord.Guide, EventDate = viewOtgulRecord.EventDate, Comment = viewOtgulRecord.Comment }); }
public async Task <ActionResult <ViewOtgulRecord> > PostOtgulRecord(int userId, [FromBody] ViewOtgulRecord viewOtgulRecord) { OtgulRecord otgulRecord = _mapper.Map(viewOtgulRecord); if (!_otgulRecordService.CheckExistRecord(otgulRecord)) { return(_mapper.Map(_otgulRecordService.CreateOtgulRecord(otgulRecord))); } else { return(BadRequest("Такая запись уже существует.")); } }