Esempio n. 1
0
        public virtual ActionResult Create(string special, CommissionModel commissionModel)
        {
            ModelState.Remove("Id");
            if (!ModelState.IsValid)
            {
                return(Json(new { isError = true, Message = "ورودی نامعتبر!" }));
            }
            //var userId = long.Parse(User.Identity.GetUserId());
            //var data = _personManagementService.IsStudentExist(commissionModel.StudentNumber, userId,
            //            commissionModel.RequestType).Result;
            //if (!data.Item1)
            //    return Json(new { isError = true, Message = data.Item2 });

            string[] arrSpecialEducations = special.Split('&');
            if (arrSpecialEducations.Length > 1)
            {
                string[] fields;
                long     specialId;

                for (var i = 0; i < arrSpecialEducations.Length - 1; i++)
                {
                    fields    = arrSpecialEducations[i].Split(',');
                    specialId = Convert.ToInt64(fields[0]);
                    CommissionSpecialEducation commissionSpecialEducation = new CommissionSpecialEducation
                    {
                        // CommissionId = Convert.ToInt64(commissionModel.Id),
                        SpecialEducationId = specialId
                    };
                    commissionModel.CommissionSpecialEducations.Add(commissionSpecialEducation);
                }
            }
            var userAuthenticationType = (AuthenticationType)Enum.Parse(typeof(AuthenticationType), User.AuthenType(), true);
            var levelId = Convert.ToInt64(User.LevelId());

            commissionModel.RequestType   = RequestType.Comision;
            commissionModel.RequestStatus = RequestStatus.Waiting;
            var result = _comissionService.AddCommissionRequest(commissionModel, levelId);

            return(Json(new { isError = !result.Item1, Message = result.Item2, requestId = result.Item3 }));
        }