public ActionResult OnPost() { if (ModelState.IsValid) { Models.Linhas newLinha = new Models.Linhas(); Models.Ticket ticket = new Models.Ticket(); newLinha.Number = number.Trim().ToLower(); newLinha.Description = description.Trim().ToLower(); ticket.ID = TicketID; newLinha.Ticket = ticket; if (Call.Calls.CreateLines(newLinha).Result) { return(RedirectToPage("Linhas")); } else { Message = "Erro ao realizar operação!"; return(Page()); } } else { return(Page()); } }
public void PreencherListaLinhas(DataTable dt) { foreach (DataRow row in dt.Rows) { lines = new Models.Linhas(); Models.Ticket ticket = new Models.Ticket(); lines.ID = Guid.Parse(row.ItemArray[0].ToString()); lines.Number = row.ItemArray[1].ToString(); lines.Description = row.ItemArray[2].ToString(); ticket.ID = Guid.Parse(row.ItemArray[3].ToString()); ticket.Price = decimal.Parse(row.ItemArray[4].ToString()); lines.Ticket = ticket; linhas.Add(lines); } }