Esempio n. 1
0
        internal bool SaveTutorSchedule(TutorScheduleModel objReq)
        {

            using (var db = new WizzDataContext())
            {
                try
                {
                    long userId = Convert.ToInt64(objReq.userId);
                    #region Deleting old data on behalf of user Id
                    var scheduleList = db.tblTutorSchedules.Where(x => x.fkUserId == userId).ToList();
                    List<tblTutorSchedule> objScheduleList = new List<tblTutorSchedule>();
                    if (scheduleList.Count > 0)
                    {

                        db.tblTutorSchedules.DeleteAllOnSubmit(scheduleList);
                        db.SubmitChanges();
                    }
                    #endregion

                    foreach (var n in objReq.scheduleList)
                    {
                        tblTutorSchedule objSchedule = new tblTutorSchedule();
                        objSchedule.fkUserId = userId;
                        objSchedule.fromTime = timeConversionMethod(n.fromTime);
                        objSchedule.toTime = timeConversionMethod(n.toTime);
                        objSchedule.isDelete = false;
                        objSchedule.dayType = Convert.ToInt16(n.dayType);
                        objSchedule.createdDate = DateTime.UtcNow;
                        objScheduleList.Add(objSchedule);
                    }
                    db.tblTutorSchedules.InsertAllOnSubmit(objScheduleList);
                    db.SubmitChanges();
                    return true;

                }
                catch (Exception)
                {

                    return false;
                }

            }
            return false;

        }
Esempio n. 2
0
        internal UserResponse GetUserRequest(RequestEntity objReq)
        {
            UserResponse objResponse = new UserResponse();
            using (var db = new WizzDataContext())
            {
                if (objReq.isTutor.ToLower() == "true")
                {


                }
                else
                {
                    var tutorData = db.tblTutorSchedules.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId)).ToList();

                    TutorScheduleModel objTutor = new TutorScheduleModel();
                    objTutor.userId = objReq.userId;
                    DayTimeModel dtmObj = new DayTimeModel();
                    foreach (var n in tutorData)
                    {
                        dtmObj = new DayTimeModel();
                        dtmObj.dayType = Convert.ToString(n.dayType);
                        dtmObj.fromTime = ReverseTimeConversionMethod(n.fromTime);
                        dtmObj.toTime = ReverseTimeConversionMethod(n.toTime);
                        objTutor.scheduleList.Add(dtmObj);
                    }

                    objResponse.tutorObj = objTutor;
                }
               
                return objResponse;
                //throw new NotImplementedException();
            }
        }
        public Response<string> SaveTutorSchedule(TutorScheduleModel 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.SaveTutorSchedule(objReq))
                            response.Create(true, "Tutor Schedule 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;
        }