Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 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");
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        // POST: api/Psychologist
        public async Task <IHttpActionResult> Post([FromBody] TEntity value)
        {
            try
            {
                var result = await _repo.AddAsync(value);

                return(Ok(result));
            }
            catch
            {
                return(BadRequest());
            }
        }
Exemplo n.º 5
0
        /// <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));
        }