public async Task <ActionResult> Create([FromBody] CreateSellerContactDTO sellerContactDTO) { SellerContact sellerContact = _mapper.Map <SellerContact>(sellerContactDTO); await _sellerContactRepository.CreateAsync(sellerContact); return(CreatedAtRoute("GetSellerContactById", new { sellerContact.Id }, sellerContact)); }
public async Task <ActionResult <SellerContact> > GetById([FromRoute] int id) { SellerContact sellerContact = await _sellerContactRepository.FindByIdAsync(id); if (sellerContact.IsNull()) { return(NotFound()); } return(Ok(sellerContact)); }
public void ContactAgent(SellerContact contact, string receipient) { WebClient client = new WebClient(); NameValueCollection values = new NameValueCollection(); values.Add("username", receipient); values.Add("api_key", _configuration["Email:api_key"]); values.Add("from", contact.Email); values.Add("from_name", contact.Name); values.Add("body_html", contact.Message); values.Add("to", receipient); client.UploadValuesAsync(new Uri("https://api.elasticemail.com/mailer/send"), values); }
public async Task <ActionResult> Update([FromRoute] int id, [FromBody] UpdateSellerContactDTO sellerContactDTO) { SellerContact sellerContact = await _sellerContactRepository.FindByIdAsync(id); if (sellerContact.IsNull()) { return(NotFound()); } _mapper.Map(sellerContactDTO, sellerContact); await _sellerContactRepository.UpdateAsync(sellerContact); return(NoContent()); }
public async Task <ActionResult> UpdatePartial([FromRoute] int id, [FromBody] JsonPatchDocument <UpdateSellerContactDTO> pacthSellerContactDTO) { SellerContact sellerContact = await _sellerContactRepository.FindByIdAsync(id); if (sellerContact.IsNull()) { return(NotFound()); } UpdateSellerContactDTO sellerDTO = _mapper.Map <UpdateSellerContactDTO>(sellerContact); pacthSellerContactDTO.ApplyTo(sellerDTO); if (!TryValidateModel(sellerDTO)) { return(ValidationProblem(ModelState)); } _mapper.Map(sellerDTO, sellerContact); await _sellerContactRepository.UpdateAsync(sellerContact); return(NoContent()); }
public async Task UpdateAsync(SellerContact obj) { _dataContext.SellerContact.Update(obj); await _dataContext.SaveChangesAsync(); }
public async Task DeleteAsync(SellerContact obj) { _dataContext.SellerContact.Remove(obj); await _dataContext.SaveChangesAsync(); }