/// <summary> /// Pushes the information to the <c>crm</c> /// </summary> /// <param name="crm"> /// The <see cref="AgileCRM"/> instance /// </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous operation. /// </returns> public async Task PushAsync(AgileCRM crm) { var exists = await this.ExistsAsync(crm).ConfigureAwait(false); if (!exists) { var newPersonRequest = new NewPersonRequest(this); var updatedContact = await crm.RequestAsync("contacts", HttpMethod.Post, JsonConvert.SerializeObject(newPersonRequest)).ConfigureAwait(false); this.Contact.Update(JsonConvert.DeserializeObject <Contact>(updatedContact)); } else { // make sure the contact id is initialized if (this.Contact.Id == 0) { var person = new Person(this.Email); await person.PullAsync(crm).ConfigureAwait(false); this.Contact.Id = person.Contact.Id; } // update properties var updatePropertiesRequest = new UpdateContactPropertiesRequest(this.Contact); await crm.RequestAsync("contacts/edit-properties", HttpMethod.Put, JsonConvert.SerializeObject(updatePropertiesRequest)).ConfigureAwait(false); // update lead score var updateLeadScoreRequest = new UpdateLeadScoreRequest(this.Contact); await crm.RequestAsync("contacts/edit/lead-score", HttpMethod.Put, JsonConvert.SerializeObject(updateLeadScoreRequest)).ConfigureAwait(false); // update star value var updateStarValueRequest = new UpdateStarValueRequest(this.Contact); await crm.RequestAsync("contacts/edit/add-star", HttpMethod.Put, JsonConvert.SerializeObject(updateStarValueRequest)).ConfigureAwait(false); } }
public Persona Put(string id, [FromBody] NewPersonRequest request) { var per = new Persona(); // mapeo tendria q ver para hacer el autoMapper per.Nombre = request.Nombre; per.Edad = request.Apellido; per.Apellido = request.Edad; _personadal.UpdateOne(id, per); return(per); }
public static Person ToPerson(this NewPersonRequest newPersonRequest) { Person person = new Person(); person.Name = newPersonRequest.Name; person.LastName = newPersonRequest.LastName; person.Age = newPersonRequest.Age; person.Address = newPersonRequest.Address; person.Vd = newPersonRequest.Vd; person.Rut = newPersonRequest.Rut; return(person); }
public ActionResult <PersonDto> Post(NewPersonRequest newPersonRequest) { _logger.LogInformation("PersonController.Post", newPersonRequest); ModelStateDictionary modelState = ValidateRut(newPersonRequest.Rut, newPersonRequest.Vd, nameof(newPersonRequest.Vd)); if (modelState != null) { return(ValidationProblem(modelState)); } Person person = newPersonRequest.ToPerson(); person = _context.Persons.Add(person).Entity; _context.SaveChanges(); return(Ok(person.ToPersonDto())); }
private void CreateNewPerson() { NewPersonRequest.Raise(new NewPersonNotification { Title = "Create a New Person Entry" }, r => { if (r.Confirmed) { int newPersonID = _ps.AddNewPerson(new Person() { FirstName = r.FirstName, LastName = r.LastName }); NavigateToPersonEntry(newPersonID); } } ); }
public void TestEnvioEmail() { // arrange var fakesender = new Fakesender(); var fakePersonaDal = new FakePersonaDal(); var controller = new ValuesController(fakesender, fakePersonaDal); var per = new NewPersonRequest(); per.Apellido = "casa"; per.Nombre = "auto"; per.Edad = "20"; // act var personas = controller.Post(per); // assert Assert.AreEqual("auto", fakesender.MensajeEnviado); }
public async Task <IActionResult> Post([FromBody] NewPersonRequest request) { var mensaje = "Se a agregado un nuevo elemento a la colleccion "; if (request.Nombre == "" || request.Apellido == "") { return(BadRequest()); } var pe1 = new Persona(); // mapear pe1.Nombre = request.Nombre; pe1.Apellido = request.Apellido; pe1.Edad = request.Edad; await _personadal.InsertOneAsync(pe1); await _emailSender.NewMessageAsync(mensaje, pe1); return(Ok()); }