public async Task <VMEntity> CreateNewGeneric(VMEntity genericmodel) { var toInsert = _mapper.Map <TEntity>(genericmodel); await _rep.AddAsync(toInsert); await _unitOfWork.CompleteAsync(); return(_mapper.Map <VMEntity>(toInsert)); }
public async Task<IActionResult> Add(Person person) { //var person = new Person(); if (ModelState.IsValid) { await _repo.AddAsync(person); return RedirectToAction("Details", new { id = person.ID }); } return RedirectToAction("Index"); }
public async Task <int> CreateAsync(string name, int phone, int sauceid) { var hotDog = new HotDog() { Name = name, Phone = phone, SauceId = sauceid }; await _repo.AddAsync(hotDog); return(hotDog.Id); }
// POST: api/Psychologist public async Task <IHttpActionResult> Post([FromBody] TEntity value) { try { var result = await _repo.AddAsync(value); return(Ok(result)); } catch { return(BadRequest()); } }
/// <inheritdoc /> public virtual async Task <TDto> Create(TDto entity) { var entityFromDto = _mapper.Map <TDto, TEntity>(entity); await BeforeCreate(entityFromDto); await _repository.AddAsync(entityFromDto); await AfterCreate(entityFromDto); await CommitAsync(); var insertedEntity = await _repository.GetByIdAsync(entityFromDto.Id); return(_mapper.Map <TEntity, TDto>(insertedEntity)); }