public OtgulRecord CreateOtgulRecord(OtgulRecord otgulRecord) { OtgulRecord newOtgulRecord = _otgulRecordRepository.Create(otgulRecord); _otgulRecordRepository.Save(); return(newOtgulRecord); }
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("Такая запись уже существует.")); } }
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 ViewOtgulRecord Map(OtgulRecord otgulRecord) { return(new ViewOtgulRecord { Id = otgulRecord.Id, User = Map(otgulRecord.User), Action = otgulRecord.Action, MinutCount = otgulRecord.MinutCount, Date = otgulRecord.Date, Guide = otgulRecord.Guide, EventDate = otgulRecord.EventDate, Comment = otgulRecord.Comment, Initiator = Map(otgulRecord.Initiator), }); }
public bool CheckExistRecord(OtgulRecord otgulRecord) { IEnumerable <OtgulRecord> tmpOtgulRecord = _otgulRecordRepository.Find(record => record.User.Id == otgulRecord.User.Id && record.Action == otgulRecord.Action && record.MinutCount == otgulRecord.MinutCount && record.Date == otgulRecord.Date && record.Guide.Id == otgulRecord.Guide.Id ); if (tmpOtgulRecord == null) { return(false); } else { return(true); } }
public void UpdateOtgulRecord(OtgulRecord otgulRecord) { _otgulRecordRepository.Update(otgulRecord); _otgulRecordRepository.Save(); }