Beispiel #1
0
        public async Task <DataResult <FamilyModel> > CreateFamily(FamilyModel model)
        {
            try
            {
                Family entity = _mapper.MapBack(model);

                DataResult <Family> result = await _familyRepository.Add(entity);

                return(new DataResult <FamilyModel>
                {
                    Success = result.Success,
                    ErrorCode = result.ErrorCode,
                    Data = _mapper.Map(result.Data),
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Problems with creating Family");
                return(new DataResult <FamilyModel>
                {
                    Success = false,
                    ErrorCode = ErrorCode.InternalError,
                });
            }
        }
Beispiel #2
0
        public ActionResult <Family> PostFamily(Family family)
        {
            _familyRepository.Add(family);
            _familyRepository.Save();

            return(CreatedAtAction("GetFamily", new { id = family.Id }, family));
        }
        public async Task <ActionResult <FamilyDTO> > PostFamily(FamilyDTO familyDTO)
        {
            try
            {
                var mappedEntity = _mapper.Map <Family>(familyDTO);
                _familyRepository.Add(mappedEntity);
                if (await _familyRepository.Save())
                {
                    return(Created($"/api/v1.0/family/id{familyDTO.FamilyID}", _mapper.Map <FamilyDTO>(mappedEntity)));
                }
            }

            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"database failure {e.Message}"));
            }

            return(BadRequest());
        }
Beispiel #4
0
 public Family Add(Family family)
 {
     _familyRepository.Add(family);
     return(family);
 }
 public void CreateFamily(Family Family, string userName)
 {
     Family.DateCreated       = DateTime.Now;
     Family.CreatedByUserName = userName;
     _repository.Add(Family);
 }