Exemplo n.º 1
0
        public int ApplayPro(ProjectSign prosign)
        {
            using (var db = new EFContext())
            {
                int result = 0;

                //首先检查该学员有没有已经报过名该项目

                ProjectSign prosigns = db.ProjectSign.FirstOrDefault(x => x.ProjectId == prosign.ProjectId && x.StudentId == prosign.StudentId);

                if (prosigns != null && prosigns.ProjectStatus != 3)
                {
                    result = 2;//代表已经报过名了
                    return(result);
                }
                else
                {
                    db.ProjectSign.Add(prosign);

                    result = db.SaveChanges();

                    return(result);
                }
            }
        }
        public ActionResult ApplayPro(int projectid, int studentid)
        {
            JsonResultData <string> resultdata = new JsonResultData <string>();

            ProjectSign pro = new ProjectSign()
            {
                SignTime      = DateTime.Now,
                ProjectStatus = 0, //0 表示未审核,1表示审核未通过,2进行中 3已完成
                CreateTime    = DateTime.Now,
                UpdateTime    = DateTime.Now,
                ProjectId     = projectid,

                //学生
                StudentId = studentid,

                //评分

                //导师评价


                //git地址
            };

            try
            {
                int result = projectservice.ApplayPro(pro);

                if (result == 0)
                {
                    resultdata.Code = 0;
                    resultdata.Data = "申请失败";
                }
                else if (result == 1)
                {
                    resultdata.Code = 1;
                    resultdata.Data = "申请成功";
                }
                else
                {
                    resultdata.Code = 2;
                    resultdata.Data = "您已申请该项目";
                }
            }
            catch (Exception ex)
            {
                resultdata.Msg = ex.Message;
            }

            return(Json(resultdata, JsonRequestBehavior.AllowGet));
        }