public ActionResult Edit(FormCollection fc)
        {
            if (Int32.TryParse(fc["Excercise.Id"], out int id))
            {
                Excercise excercise = db.Excercises.Find(id);
                if (excercise == null)
                {
                    return(HttpNotFound());
                }
                if (float.TryParse(fc["Excercise.Length"], out float length) && int.TryParse(fc["Excercise.ExType.Id"], out int excerciseTypeId) && DateTime.TryParse(fc["Excercise.Date"], out DateTime date))
                {
                    ExcerciseType excerciseType = db.ExcerciseTypes.Find(excerciseTypeId);
                    if (excerciseType == null)
                    {
                        return(HttpNotFound());
                    }
                    excercise.ExType = excerciseType;
                    excercise.Length = length;
                    excercise.Date   = date;
                    db.SaveChanges();

                    db.Entry(excercise).Reference(m => m.ExType).Load();
                    return(RedirectToAction("Edit", excercise));
                }
            }


            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Ejemplo n.º 2
0
        private IQueryable <Excercise> AllByType(ExcerciseType type = ExcerciseType.None)
        {
            var query = db.Excercises.Where(x => x.IsDeleted == false);

            if (type != ExcerciseType.None)
            {
                query = query.Where(x => x.ExcerciseType == type);
            }

            return(query);
        }
Ejemplo n.º 3
0
    /// <summary>
    /// 修行请求 1铜钱运功 2元宝运功 3高人指点 4仙人指点 5 十倍运功
    /// </summary>
    public void C2S_ReqExcercise(ExcerciseType stege)
    {
        if (stege == ExcerciseType.TENTIMESYG)
        {
            isTenTimesYG = true;
        }
        //Debug.logger.Log("请求1铜钱运功 2元宝运功 3高人指点 4仙人指点 5 十倍运功 :" + (uint)stege);
        pt_req_xiuxing_d476 msg = new pt_req_xiuxing_d476();

        msg.state = (uint)stege;
        NetMsgMng.SendMsg(msg);
    }
Ejemplo n.º 4
0
 public async Task <Result <IEnumerable <ExcerciseListingModel> > > GetByType(ExcerciseType type)
 => await mapper.ProjectTo <ExcerciseListingModel>(this.AllByType(type))
 .ToListAsync();
 public async Task <ActionResult <IEnumerable <ExcerciseListingModel> > > GetByType(ExcerciseType type)
 => await excerciseService.GetByType(type);