public Response<string> SetTutorSubjects(TutorSubjectModel objReq)
        {
            Response<string> response = new Response<string>();
            List<string> objResp = new List<string>();


            try
            {
                if (ModelState.IsValid)
                {
                    objDbMethodV2 = new wizz.Dal.DbMethodsV2();
                    if (CheckRequestIsvalidornot(this.Request))
                    {
                        if (objDbMethodV2.SetTutorSubjects(objReq))
                            response.Create(true, "Tutor subjects saved successfully", Messages.AppVersion, objResp);
                    }
                    else
                    {
                        response.Create(false, Messages.FormatMessage(Messages.InvalidReq), Messages.AppVersion, objResp);
                    }
                }
                else
                    response.Create(false, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage, 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);
            }
            return response;
        }
Пример #2
0
        internal bool SetTutorSubjects(TutorSubjectModel objReq)
        {

            using (var db = new WizzDataContext())
            {


                List<tblTutorSubject> objTutorSubList = new List<tblTutorSubject>();
                Int64 userId = Convert.ToInt64(objReq.userId);
                objTutorSubList = db.tblTutorSubjects.Where(x => x.fkTutorId == userId).ToList();
                if (objTutorSubList.Count > 0)
                {
                    db.tblTutorSubjects.DeleteAllOnSubmit(objTutorSubList);
                    db.SubmitChanges();
                    objTutorSubList = new List<tblTutorSubject>();
                }

                if (objReq.subjectIdList.Count > 0)
                    foreach (var n in objReq.subjectIdList)
                    {
                        tblTutorSubject objTutorSubject = new tblTutorSubject();
                        objTutorSubject.isApproved =Convert.ToBoolean(n.isApproved);

                        objTutorSubject.fkSubjectId = Convert.ToInt32(n.id);
                        objTutorSubject.fkTutorId = userId;
                        objTutorSubject.subjectType = 3;
                        objTutorSubList.Add(objTutorSubject);
                    }
                if (objReq.classIdList.Count > 0)
                    foreach (var n in objReq.classIdList)
                    {
                        tblTutorSubject objTutorSubject = new tblTutorSubject();
                        objTutorSubject.isApproved = Convert.ToBoolean(n.isApproved);
                        objTutorSubject.fkSubjectId = Convert.ToInt32(n.id);
                        objTutorSubject.fkTutorId = userId;
                        objTutorSubject.subjectType = 2;
                        objTutorSubList.Add(objTutorSubject);
                    }
                if (objReq.courseIdList.Count > 0)
                {

                    foreach (var n in objReq.courseIdList)
                    {
                        tblTutorSubject objTutorSubject = new tblTutorSubject();
                        objTutorSubject.isApproved = Convert.ToBoolean(n.isApproved);
                        objTutorSubject.fkSubjectId = Convert.ToInt32(n.id);
                        objTutorSubject.fkTutorId = userId;
                        objTutorSubject.subjectType = 1;
                        objTutorSubList.Add(objTutorSubject);
                    }
                }
                db.tblTutorSubjects.InsertAllOnSubmit(objTutorSubList);
                db.SubmitChanges();
            }
            return true;
        }