public ActionResult CreateWorkOrder() { var model = new CreateWorkOrder { AvailableTests = GetTests() }; return(View(model)); }
public async Task <UpsertResponse <WorkOrder> > PostWo(CreateWorkOrder wo) { var body = JsonConvert.SerializeObject(wo); await AuthorizeIfNeeded(); var url = _baseUri + "/apis/360facility/v1/workorders?"; var content = new StringContent(body, Encoding.UTF8, "application/json"); var response = await _client.PostAsync(url, content); if (response.IsSuccessStatusCode) { var successWo = JsonConvert.DeserializeObject <WorkOrder>( await response.Content.ReadAsStringAsync()); return(new UpsertResponse <WorkOrder>(true, null, successWo)); } var failResponse = JsonConvert.DeserializeObject <FamisHttpResponse>( await response.Content.ReadAsStringAsync()); return(new UpsertResponse <WorkOrder>(false, failResponse.Message, null)); }
public ActionResult CreateWorkOrder(CreateWorkOrder order) { if (ModelState.IsValid) { Compound compound = new Compound(); string Id = User.Identity.GetUserId(); if (Id == null) { ViewBag.ErrorMessage = "Please sign in before submitting an order."; return(View("Error")); } else if (order.SelectedTests.Count == 0) { ViewBag.ErrorMessage = "Please select a test to perform"; return(View("Error")); } int LT = db.Database.SqlQuery <int>( "SELECT MAX(LT) + 1 FROM Compound").FirstOrDefault(); order.LT = LT; order.StatusID = 1; int OrderID = db.Database.SqlQuery <int>( "SELECT MAX(OrderID) + 1 FROM WorkOrder").FirstOrDefault(); order.OrderID = OrderID; int ClientID = db.Database.SqlQuery <int>( "SELECT ClientID FROM ClientEmployee WHERE Id = '" + Id + "'").FirstOrDefault(); order.ClientID = ClientID; DateTime date = DateTime.Now; db.Database.ExecuteSqlCommand( "INSERT INTO WorkOrder (OrderID, ClientID, CustomerComments, IsExpedited, DateCreated) " + "VALUES (" + order.OrderID + ", " + order.ClientID + ", '" + order.CustomerComments + "', " + Convert.ToInt16(order.IsExpedited) + ", '" + date + "')" ); db.Database.ExecuteSqlCommand( "INSERT INTO Compound (LT, OrderID, ClientID, CompoundName, MolecularMass, StatusID, InvoiceID) " + "VALUES (" + order.LT + ", " + order.OrderID + ", " + order.ClientID + ", '" + order.CompoundName + "', " + order.MolecularMass + ", 1, null)" ); /*Compound pound = new Compound(); * pound.LT = LT; * pound.OrderID = OrderID; * pound.CompoundName = order.CompoundName; * pound.MolecularMass = order.MolecularMass; * pound.StatusID = 1; * db.Compounds.Add(pound);*/ foreach (string i in order.SelectedTests) { OrderTest ot = new OrderTest(); ot.OrderID = order.OrderID; ot.TestTypeID = Convert.ToInt32(i); db.OrderTests.Add(ot); } db.SaveChanges(); return(View("ThankYou")); } return(View(order)); }