static void Main() { Thread thread = new Thread(); // 判斷訂單裡有沒有正在進行中的資料 Order old_order = orderService.Get().Where(a => a.OrderStatus == 1).OrderBy(o => o.Createdate).FirstOrDefault(); if (old_order == null) { // 判斷訂單裡有沒有等待中的資料 Order order = orderService.Get().Where(a => a.OrderStatus == 0).OrderBy(o => o.Createdate).FirstOrDefault(); if (order != null) { string response; string OrderNumber = order.Ordernumber; // 將訂單狀態改為進行中 order.OrderStatus = 1; orderService.SpecificUpdate(order, new string[] { "OrderStatus" }); orderService.SaveChanges(); // 將此筆丟到排程裡 response = HeO.Libs.Threadwork.set_thread(order); thread.Logs = response; thread.Createdate = DateTime.Now; threadService.Create(thread); threadService.SaveChanges(); // 將訂單狀態改為完成中 Order thisorder = orderService.Get().Where(a => a.Ordernumber == OrderNumber).OrderBy(o => o.Createdate).FirstOrDefault(); thisorder.OrderStatus = 2; orderService.SpecificUpdate(thisorder, new string[] { "OrderStatus" }); orderService.SaveChanges(); } } }
public ActionResult Create(CreateThreadViewModel model) { try { return(RedirectToAction("Preview", new { id = threadService.Create(model) })); } catch (NoCategoryException e) { return(View("NoCategory")); } catch (CouldntCreateThread e) { } return(RedirectToAction("Index", "Home", new { })); }
public bool AddThread([FromBody] Thread thread) { if (thread == null) { return(false); } // Thread thread = Models.Thread.Converter (threadDto); // Ajouter un nouveau thread et dans user.threads Thread newThread = _threadService.Create(thread); foreach (var userId in thread.Speakers) { bool isAddedInUsers = _userService.AddThread(thread.Id, userId); } return(newThread != null); // Doit être approfondie, regarer aussi chaque "AddThread" }
public ActionResult <Thread> Create(Thread thread) { _threadService.Create(thread); return(CreatedAtRoute("GetThread", new { id = thread.Id.ToString() }, thread)); }