public async Task <StatusCodeResult> Post01([FromBody] Checkout lego) { b = lego.userEmail + lego.list.Name; checkoutlist = (System.Collections.Generic.List <Asplego.Models.Checkout>)cm.GetAll; foreach (var element in checkoutlist) { a = element.userEmail + element.list.Name; alist.Add(a); } if (!checkoutlist.Count.Equals(0)) { if (alist.Contains(b)) { foreach (var i in cm.GetAll) { if (lego.list.Name.Equals(i.list.Name) && lego.userEmail.Equals(i.userEmail)) { i.count += 1; } } } else { cm.AddLego(lego); } } else { cm.AddLego(lego); } return(new StatusCodeResult(201)); //created } }