public async Task <HomepageInfoDTO> Create(HomepageInfoDTO modelDTO) { var model = _mapper.Map <HomepageInfoDTO, HomepageInfo>(modelDTO); var create = _db.HomepageInfos.Add(model); await _db.SaveChangesAsync(); return(_mapper.Map <HomepageInfo, HomepageInfoDTO>(create.Entity)); }
public async Task <HomepageInfoDTO> Update(int id, HomepageInfoDTO modelDTO) { if (id == modelDTO.Id) { var modelDetails = await _db.HomepageInfos.FirstOrDefaultAsync(x => x.Id == id); var model = _mapper.Map <HomepageInfoDTO, HomepageInfo>(modelDTO, modelDetails); var updateModel = _db.HomepageInfos.Update(model); await _db.SaveChangesAsync(); return(_mapper.Map <HomepageInfo, HomepageInfoDTO>(updateModel.Entity)); } else { return(null); } }