public static bool Save(Lead lead) { if (!leads.ContainsKey(lead.Email)) { //email no exists then add leads.Add(lead.Email, new List <Lead> { lead }); LeadLog.writeTofile(lead); return(true); } else { if (LeadRepository.Get(lead.Email, lead.CorrelationId) == null) { //Email with this Id isn't exist then add var listLead = leads.Where(x => x.Key == lead.Email).Select(x => x.Value).SingleOrDefault(); listLead.Add(lead); leads[lead.Email] = listLead; LeadLog.writeTofile(lead); return(true); } else { //the email with this correlationId has already existed. return(false); } } }
public IHttpActionResult Get(string email, string correlationId) { var lead = LeadRepository.Get(email, correlationId); if (lead != null) { return(Content(HttpStatusCode.OK, lead)); } else { HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.NotFound); message.Content = new StringContent("the lead is not existed."); throw new HttpResponseException(message); } }