public async Task <ActionResult> Create(ConstructionTask constructionTask)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _task.CreateConstructionTask(constructionTask);

                    return(RedirectToAction("IndexAdminTask"));
                }
                catch
                {
                    return(RedirectToAction("BadRequest", "Home"));
                }
            }
            if (constructionTask.WorkerTypeId == null)
            {
                ViewBag.Worker = new SelectList(await _task.GetWorkerTypes(), "Id", "Type");
            }
            else
            {
                ViewBag.Worker = new SelectList(await _task.GetWorkerTypes(), "Id", "Type", constructionTask.WorkerTypeId);
            }

            return(View(constructionTask));
        }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     taskManager  = GameObject.FindWithTag("GameManager").GetComponent <TaskManager>();
     anim         = GetComponent <WorkerAnimationManager>();
     delivery     = GetComponent <DeliveryTask>();
     construction = GetComponent <ConstructionTask>();
     hasTask      = false;
 }
Esempio n. 3
0
 public async Task CreateConstructionTask(ConstructionTask task)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         task.Id = Guid.NewGuid();
         context.ConstructionTask.Add(task);
         await context.SaveChangesAsync();
     }
 }
Esempio n. 4
0
 public virtual void InitializeTasks()
 {
     IdleTask.Enable();
     ProductionTask.Enable();
     WorkerTask.Enable();
     ConstructionTask.Enable();
     MorphingTask.Enable();
     WorkerDefenseTask.Enable();
 }
Esempio n. 5
0
 public virtual void InitializeTasks()
 {
     IdleTask.Enable();
     ProductionTask.Enable();
     WorkerTask.Enable();
     ConstructionTask.Enable();
     MorphingTask.Enable();
     WorkerDefenseTask.Enable();
     if (Tyr.Bot.MyRace == Race.Terran)
     {
         ConstructingSCVsTask.Enable();
     }
     GasWorkerTask.Enable();
 }
Esempio n. 6
0
 public async Task EditConstructionTask(ConstructionTask task)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         var update = context.ConstructionTask.Find(task.Id);
         if (update != null)
         {
             update.TaskName        = task.TaskName;
             update.TaskDescription = task.TaskDescription;
             update.RatePerHour     = task.RatePerHour;
             update.WorkerTypeId    = task.WorkerTypeId;
             update.IsDeleted       = task.IsDeleted;
             await context.SaveChangesAsync();
         }
     }
 }