Exemplo n.º 1
0
        internal RespIsTeacherRequest isTeacher(IsTeacherRequest objReq)
        {
            var isTutor = Convert.ToBoolean(objReq.isTutor);
            RespIsTeacherRequest response = new RespIsTeacherRequest();
            response.isAlreadySignup = "False"; 
            using (var db = new WizzDataContext())
            {
               
                tblUser tUser = new tblUser();
                int fkuserid = Convert.ToInt32(objReq.userId);
                tUser = db.tblUsers.Where(x => x.pkUserId == fkuserid).FirstOrDefault();
                if (tUser == null)
                    response.isTutor="False";
                   // return false;
                else
                {
                    var tutor = db.tblTutorProfiles.Where(t => t.fkUserId == fkuserid).FirstOrDefault();
                    //check already signup or not
                   
                    if (tutor==null)
                    {
                        response.isAlreadySignup = "False"; 
                    }
                    else
                    {
                        response.isAlreadySignup = "True";
                    }
                    


                    if (tutor == null && objReq.isTutor=="True")
                    {
                        response.isAlreadySignup = "False";
                    }
                    else
                    {
                        response.isTutor = isTutor.ToString();
                        tUser.isTeacher = isTutor;
                        db.SubmitChanges();
                    }

                  //  return true;
                }
            }
          return  response;
        }
        public Response<RespIsTeacherRequest> ChangeTutorStatus(IsTeacherRequest objReq)
        {
            Response<RespIsTeacherRequest> response = new Response<RespIsTeacherRequest>();
            List<RespIsTeacherRequest> objResp = new List<RespIsTeacherRequest>();
            try
            {
                WebMethods objDBMethod = new WebMethods();

                if (CheckRequestIsvalidornot(this.Request))
                {
                    if (ModelState.IsValid)
                    {
                        objResp.Add(objDBMethod.isTeacher(objReq));
                        if (objResp != null)
                        {

                            response.Create(true, Messages.FormatMessage(Messages.Success, "Status Changed"), Messages.AppVersion, objResp);

                        }
                        else
                        {

                            response.Create(false, Messages.ErrorOccure, Messages.AppVersion, objResp);
                        }



                    }
                    else
                        response.Create(false, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage, Messages.AppVersion, objResp);
                }
                else
                    response.Create(false, Messages.FormatMessage(Messages.InvalidReq), Messages.AppVersion, objResp);

            }
            catch (Exception ex)
            {
                object session = new JavaScriptSerializer().Serialize(objReq);
                LogManager.Error("Error occured while Processing Webservice request :{0}", ex, session, ex.Message);
                response.Create(false, Messages.FormatMessage(Messages.ErrorOccure), Messages.AppVersion, objResp);
            }
            finally
            {
            }
            return response;
        }