public virtual Lead GetLead(BusinessTypes type) { if (Contact == null) throw new Exception("Can not generate lead from an empty contact"); if (Contact.Site == null) throw new Exception("Can not generate lead without a valid site"); var phone = Phone ?? GetPhoneNumber(Contact); if (phone == null) throw new Exception("Invalid phone number"); var lead = new Lead { Address = new Address { Number = Contact.Site.Number, Street = Contact.Site.Street, Suburb = Contact.Site.Suburb, Unit = Contact.Site.Unit }, ContactId = Contact.Id, Phone = phone, Postcode = Contact.Site.Postcode, State = Contact.Site.State, BusinessTypeId = (int)type, LeadStatusId = (int)LeadStatusTypes.New }; var time = DateTime.Now; lead.CreatedDate = time; lead.LastUpdateDate = time; return lead; }
public IHttpActionResult PostLead(Lead lead) { if (!ModelState.IsValid) return BadRequest(ModelState); DateTime time = DateTime.Now; lead.CreatedDate = time; lead.LastUpdateDate = time; return Ok(new { data = _leadService.Add(lead) }); }