Пример #1
0
        public OtgulRecord CreateOtgulRecord(OtgulRecord otgulRecord)
        {
            OtgulRecord newOtgulRecord = _otgulRecordRepository.Create(otgulRecord);

            _otgulRecordRepository.Save();
            return(newOtgulRecord);
        }
Пример #2
0
        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("Такая запись уже существует."));
            }
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
 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),
     });
 }
Пример #5
0
        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);
            }
        }
Пример #6
0
 public void UpdateOtgulRecord(OtgulRecord otgulRecord)
 {
     _otgulRecordRepository.Update(otgulRecord);
     _otgulRecordRepository.Save();
 }