Beispiel #1
0
    public IEnumerator WaitAppropriately(TimeCategory timeCategory)
    {
        switch (timeCategory)
        {
        case TimeCategory.Math:
            yield break;

        case TimeCategory.Logic:
            yield return(new WaitForSeconds(0.2f));

            break;

        case TimeCategory.MemoryOperation:
            yield return(new WaitForSeconds(0.3f));

            break;

        case TimeCategory.StartNode:
            yield return(new WaitForSeconds(0.4f));

            break;

        case TimeCategory.CharacterAction:
            yield return(new WaitForSeconds(0.8f));

            break;
        }
    }
        public async Task <ActionResult> Delete(short id)
        {
            TimeCategory timeCategory = await db.TimeCategory.FindAsync(id);

            db.TimeCategory.Remove(timeCategory);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public ActionResult GetTimeCategory(int id)
        {
            TimeCategory timeCategory = db.TimeCategory.Where(c => c.TimeCategoryId == id).FirstOrDefault();
            var          category     = new
            {
                categoryId = timeCategory.TimeCategoryId,
                title      = timeCategory.TimeCategoryTitle
            };

            return(Json(category, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> Create([Bind(Include = "TimeCategoryId, TimeCategoryTitle")] TimeCategory timeCategory)
        {
            if (ModelState.IsValid)
            {
                db.TimeCategory.Add(timeCategory);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(timeCategory));
        }
        public async Task <ActionResult> Edit([Bind(Include = "TimeCategoryId, TimeCategoryTitle")] TimeCategory timeCategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(timeCategory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(timeCategory));
        }
        // GET: TimeCategory/Delete/5
        public async Task <ActionResult> Delete(short?id)
        {
            if (id != null)
            {
                TimeCategory timeCategory = await db.TimeCategory.FindAsync(id);

                if (timeCategory != null)
                {
                    return(View(timeCategory));
                }
            }

            return(HttpNotFound());
        }
Beispiel #7
0
        public async Task <IHttpActionResult> PutTimeCategory(TimeCategory model)
        {
            var result = await _repository.SelectById(model.TimeCategoryId);

            if (result == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await _repository.Update(model);

            return(Ok(model));
        }
        public async Task <ApiResponse> Handle(AddEditTimeCategoryCommand request, CancellationToken cancellationToken)

        {
            ApiResponse response = new ApiResponse();

            try
            {
                if (request.TimeCategoryId == 0 || request.TimeCategoryId == null)
                {
                    TimeCategory obj = new TimeCategory();
                    obj.CreatedById      = request.CreatedById;
                    obj.CreatedDate      = request.CreatedDate;
                    obj.IsDeleted        = false;
                    obj.TimeCategoryName = request.TimeCategoryName;
                    _mapper.Map(request, obj);
                    await _dbContext.TimeCategories.AddAsync(obj);

                    await _dbContext.SaveChangesAsync();

                    response.data.timeCatergoryById = obj;
                    response.StatusCode             = StaticResource.successStatusCode;
                    response.Message = "Time Category added successfully";
                }
                else
                {
                    TimeCategory obj = await _dbContext.TimeCategories.FirstOrDefaultAsync(x => x.TimeCategoryId == request.TimeCategoryId);

                    obj.ModifiedById = request.ModifiedById;
                    obj.ModifiedDate = request.ModifiedDate;
                    _mapper.Map(request, obj);
                    await _dbContext.SaveChangesAsync();

                    response.data.timeCatergoryById = obj;
                    response.StatusCode             = StaticResource.successStatusCode;
                    response.Message = "Time category updated successfully";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }
Beispiel #9
0
        public async Task <ApiResponse> Handle(GetTimeCategoryByIdQuery request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                TimeCategory obj = await _dbContext.TimeCategories.AsNoTracking().AsQueryable().Where(x => x.TimeCategoryId == request.TimeCategoryId && x.IsDeleted == false).SingleAsync();

                response.data.timeCatergoryById = obj;
                response.StatusCode             = StaticResource.successStatusCode;
                response.Message = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }
Beispiel #10
0
        public void MakeStatus(StatusDTO data)
        {
            TimeCategory dalDataTime  = Database.TimeCategories.Get(data.TimeCategoryId);
            Order        dalDataOrder = Database.Orders.Get(data.OrderId);
            KvestRoom    dalDataKvest = Database.KvestRooms.Get(data.KvestRoomId);

            if (dalDataTime == null || dalDataOrder == null || dalDataKvest == null)
            {
                throw new ValidationException("Data - status ids` is not found", "");
            }
            Status DATA = new Status
            {
                TimeCategoryId = dalDataTime.Id,
                OrderId        = dalDataOrder.Id,
                KvestRoomId    = dalDataKvest.Id,
            };

            Database.Statuses.Create(DATA);
            Database.Save();
        }
Beispiel #11
0
        public async Task <IHttpActionResult> PostTimeCategory(TimeCategory model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var id = await _repository.Insert(model);

                string uri = Url.Link("DefaultApi", new { id });

                return(Created(uri, model.TimeCategoryId = id));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task Update(TimeCategory model)
        {
            try
            {
                _connection = Connect.Open();
                var p = new DynamicParameters();

                p.Add("@TimeCategoryValue", model.TimeCategoryValue);
                p.Add("@TimeCategoryId", model.TimeCategoryId);
                await _connection.ExecuteAsync("TimeCategoryUpdate", p, commandType : CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                throw;
            }
            finally
            {
                _connection.Dispose();
            }
        }
        public async Task <int> Insert(TimeCategory model)
        {
            try
            {
                _connection = Connect.Open();
                var p = new DynamicParameters();

                p.Add("@TimeCategoryValue", model.TimeCategoryValue);
                p.Add("@TimeCategoryId", dbType: DbType.Int32, direction: ParameterDirection.Output);

                await _connection.ExecuteAsync("TimeCategoryInsert", p, commandType : CommandType.StoredProcedure);

                return(p.Get <int>("@TimeCategoryId"));
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                throw;
            }
            finally
            {
                _connection.Dispose();
            }
        }
Beispiel #14
0
 public static void SetTimeScale(TimeCategory category, float timescale)
 {
     s_TimeScales[category] = timescale;
 }
 private Task UpdateTime(string token, int id, decimal amount, decimal originalAmount, TimeCategory category)
 {
     if (amount != originalAmount)
     {
         return(_webApi.UpdateTime(token, id, new TimeDTO
         {
             Amount = (double)amount,
             Category = category,
             Date = Date
         }));
     }
     return(Task.CompletedTask);
 }
Beispiel #16
0
 public static double Sum(this List <UserTimeDTO> users, TimeCategory category) => users.Sum(x => x.Times.Amount(category));
Beispiel #17
0
        public static double Percent(this List <UserTimeDTO> users, TimeCategory category)
        {
            double divisor = users.Sum(x => x.Times.Sum(t => t.Amount));

            return(divisor == 0 ? 0 : users.Sum(category) / divisor);
        }
Beispiel #18
0
 public static double Amount(this List <TimeDTO> times, TimeCategory category) => times.SingleOrDefault(x => x.Category == category)?.Amount ?? 0;
Beispiel #19
0
        public static double Percent(this List <TimeDTO> times, TimeCategory category)
        {
            double divisor = times.Sum(x => x.Amount);

            return(divisor == 0 ? 0 : times.Amount(category) / divisor);
        }
Beispiel #20
0
 public static float GetTimeScale(TimeCategory category)
 {
     return(s_TimeScales[category]);
 }
Beispiel #21
0
 public static float GetDeltaTime(TimeCategory category)
 {
     return(Time.deltaTime * s_TimeScales[category]);
 }
 public void SetUp()
 {
     times = new List <TimeCategory>
     {
         new TimeCategory()
         {
             Id = 1,
         },
         new TimeCategory()
         {
             Id = 2,
         },
         new TimeCategory()
         {
             Id = 3,
         },
         new TimeCategory()
         {
             Id = 4,
         },
     };
     statuses = new List <Status>
     {
         new Status()
         {
             Id = 1, OrderId = 1, KvestRoomId = 1, TimeCategoryId = 1
         },
         new Status()
         {
             Id = 2, OrderId = 2, KvestRoomId = 1, TimeCategoryId = 4
         },
         new Status()
         {
             Id = 3, OrderId = 3, KvestRoomId = 2, TimeCategoryId = 3
         },
         new Status()
         {
             Id = 4, OrderId = 4, KvestRoomId = 3, TimeCategoryId = 2
         },
     };
     orders = new List <Order>
     {
         new Order()
         {
             Id = 1, SertificateId = 1, UserName = "******", NumberOfUsers = 5,
         },
         new Order()
         {
             Id = 2, SertificateId = 5, UserName = "******", NumberOfUsers = 3,
         },
         new Order()
         {
             Id = 3, SertificateId = 6, UserName = "******", NumberOfUsers = 10,
         },
     };
     serts = new List <Sertificate>
     {
         new Sertificate()
         {
             Id = 1, SertificateNumber = 3,
         },
         new Sertificate()
         {
             Id = 2, SertificateNumber = 25,
         },
         new Sertificate()
         {
             Id = 3, SertificateNumber = 44,
         },
     };
     kvestroom = new KvestRoom()
     {
         Id = 1, AgeCategoryId = 1, UsersValueId = 1, Name = "GP", PriceForOneUser = 200
     };
     time = new TimeCategory()
     {
         Id = 1,
     };
     sert = new Sertificate()
     {
         Id = 1, SertificateNumber = 33,
     };
 }