예제 #1
0
        public ActionResult ViewAllEmailTemplate()
        {
            ViewEmailTemplateModel objViewEmailTemplateModel = new ViewEmailTemplateModel();

            try
            {
                //initial set of current page, pageSize , Total pages
                objViewEmailTemplateModel.CurrentPage = 1;
                objViewEmailTemplateModel.PageSize    = CommonUtils.PageSize;
                objViewEmailTemplateModel.TotalPages  = 0;
                //Get  SubCategory List
                serviceResponse           = objUtilityWeb.PostAsJsonAsync(WebApiURL.Email + "/GetEmailTemplateList", objViewEmailTemplateModel);
                objViewEmailTemplateModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewEmailTemplateModel>().Result : null;
                //ObjViewSubCategoryModel = objBLSubCategory.GetSubCategoryList(ObjViewSubCategoryModel);

                //Set Success Message if comes from save  page after click on save button
                if (!String.IsNullOrEmpty(Convert.ToString(TempData["SucessMessage"])))
                {
                    objViewEmailTemplateModel.Message     = Convert.ToString(TempData["SucessMessage"]);
                    objViewEmailTemplateModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower();
                    TempData["SucessMessage"]             = null;
                }

                //CaegoryDropDown(objViewEmailTemplateModel.FilterCategoryId);
                // EmailTyepDropDown(ObjViewSubCategoryModel.FilterCategoryId);
                //GroupDropDown(ObjViewSubCategoryModel.FilterGroupID);
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "ViewAllEmailTemplate", "ViewAllEmailTemplate");
            }
            //, ObjViewSubCategoryModel
            return(View("ViewAllEmailTemplate", objViewEmailTemplateModel));
        }
        public void FillQuickLinks(string QuickLinks, int CategoryID)
        {
            ViewDocumentModel ObjViewDocumentModel = new ViewDocumentModel();

            try
            {
                //initial set of current page, pageSize , Total pages
                ObjViewDocumentModel.CurrentPage = 1;
                ObjViewDocumentModel.PageSize    = int.MaxValue - 1;
                ObjViewDocumentModel.TotalPages  = 0;
                //Get  Document List
                serviceResponse      = objUtilityWeb.PostAsJsonAsync(WebApiURL.Document + "/GetDocumentList", ObjViewDocumentModel);
                ObjViewDocumentModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDocumentModel>().Result : null;
                //ObjViewDocumentModel = objBLDocument.GetDocumentList(ObjViewDocumentModel);
                if (ObjViewDocumentModel != null && ObjViewDocumentModel.DocumentList != null)
                {
                    //ViewBag.PackList = ObjViewDocumentModel.DocumentList.Where(x => x.PackIds == string.Empty && x.DocumentID != DocumentId).ToList();
                    ViewBag.QuickLinks = new MultiSelectList(ObjViewDocumentModel.DocumentList.Where(x => x.CategoryID == CategoryID).ToList(), "DocumentID", "DocumentTitle", Convert.ToString(string.IsNullOrWhiteSpace(QuickLinks) ? "" : QuickLinks).Split(",".ToCharArray()));
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "Document", "View GET");
            }
        }
        public ActionResult ViewOrder()
        {
            ViewOrderModel ObjViewOrderModel = new ViewOrderModel();

            try
            {
                //initial set of current page, pageSize , Total pages
                ObjViewOrderModel.CurrentPage = 1;
                ObjViewOrderModel.PageSize    = CommonUtils.PageSize;
                ObjViewOrderModel.TotalPages  = 0;

                //Get  Order List
                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Order + "/GetOrderList", ObjViewOrderModel);

                ObjViewOrderModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewOrderModel>().Result : null;
                //ObjViewOrderModel = objBLOrder.GetOrderList(ObjViewOrderModel);

                //Set Success Message if comes from save  page after click on save button
                if (!String.IsNullOrEmpty(Convert.ToString(TempData["SucessMessage"])))
                {
                    ObjViewOrderModel.Message     = Convert.ToString(TempData["SucessMessage"]);
                    ObjViewOrderModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower();
                    TempData["SucessMessage"]     = null;
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "Order", "View GET");
            }
            return(View("ViewOrder", ObjViewOrderModel));
        }
        public ActionResult SaveSubCategory(SubCategoryModel objSubCategoryModel, HttpPostedFileBase fileUpload)
        {
            try
            {
                if (ModelState.IsValid)
                {
                }

                if (fileUpload != null)
                {
                    string fileName        = string.Empty;
                    string destinationPath = string.Empty;
                    fileName = Path.GetFileName(fileUpload.FileName);
                    string       AttachmentType = Path.GetExtension(fileUpload.FileName);
                    Stream       fs             = fileUpload.InputStream;
                    BinaryReader br             = new BinaryReader(fs);
                    byte[]       bytes          = br.ReadBytes((Int32)fs.Length);
                    /// string ImageContent = Convert.ToBase64String(bytes);
                    objSubCategoryModel.AttachmentContent = bytes;
                    objSubCategoryModel.AttachmentName    = fileName;
                    objSubCategoryModel.AttachmentSize    = fs.Length;
                    objSubCategoryModel.AttachmentType    = AttachmentType;
                }
                objSubCategoryModel.IsActive  = true;
                objSubCategoryModel.CreatedBy = LoggedInUserID;

                //Insert or Update  SubCategory
                serviceResponse     = objUtilityWeb.PostAsJsonAsync(WebApiURL.SubCategory + "/InsertUpdateSubCategory", objSubCategoryModel);
                objSubCategoryModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <SubCategoryModel>().Result : null;

                //if error code is 0 means  SubCategory saved successfully
                if (Convert.ToInt32(objSubCategoryModel.ErrorCode) == 0)
                {
                    // Set success message
                    TempData["SucessMessage"] = "SubCategory Saved Successfully";
                    return(RedirectToAction("ViewSubCategory", "SubCategory"));
                }
                else if (Convert.ToInt32(objSubCategoryModel.ErrorCode) == 52)
                {
                    //If Errorcode is  52 means SubCategory Name is duplicate set duplicate SubCategory error message.
                    objSubCategoryModel.Message     = "SubCategory Duplicate not allowed";
                    objSubCategoryModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();
                }
                else
                {
                    //set Error Message if error code is greater than 0 but not 52 (duplicate)
                    objSubCategoryModel.Message     = "Error while adding record";
                    objSubCategoryModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();
                }
                CaegoryDropDown(objSubCategoryModel.CategoryID);
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "SubCategory", "SaveSubCategory POST");
            }
            return(View("SaveSubCategory", objSubCategoryModel));
        }
예제 #5
0
        public ActionResult SaveLawGuide(LawGuideModel objLawGuideModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                }
                objLawGuideModel.IsActive  = true;
                objLawGuideModel.CreatedBy = LoggedInUserID;

                //Insert or Update  LawGuide
                serviceResponse  = objUtilityWeb.PostAsJsonAsync(WebApiURL.LawGuide + "/InsertUpdateLawGuide", objLawGuideModel);
                objLawGuideModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <LawGuideModel>().Result : null;

                //if error code is 0 means  LawGuide saved successfully
                if (Convert.ToInt32(objLawGuideModel.ErrorCode) == 0)
                {
                    // Set success message
                    TempData["SucessMessage"] = "LawGuide Saved Successfully";
                    return(RedirectToAction("ViewLawGuide", "LawGuide"));
                }
                else if (Convert.ToInt32(objLawGuideModel.ErrorCode) == 52)
                {
                    //If Errorcode is  52 means LawGuide Name is duplicate set duplicate LawGuide error message.
                    objLawGuideModel.Message     = "LawGuide Duplicate not allowed";
                    objLawGuideModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();
                }
                else
                {
                    //set Error Message if error code is greater than 0 but not 52 (duplicate)
                    objLawGuideModel.Message     = "Error while adding record";
                    objLawGuideModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();
                }
                SubCatDropDown(objLawGuideModel.SubCategoryID, null, null);
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "LawGuide", "SaveLawGuide POST");
            }
            return(View("SaveLawGuide", objLawGuideModel));
        }
        public ActionResult List()
        {
            ViewUserLoginModel ObjViewUserLoginModel = new ViewUserLoginModel();

            try
            {
                //initial set of current page, pageSize , Total pages
                ObjViewUserLoginModel.CurrentPage = 1;
                ObjViewUserLoginModel.PageSize    = CommonUtils.PageSize;
                ObjViewUserLoginModel.TotalPages  = 0;
                //Get  SubCategory List
                serviceResponse       = objUtilityWeb.PostAsJsonAsync(WebApiURL.UserLogin + "/GetUsernameList", ObjViewUserLoginModel);
                ObjViewUserLoginModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewUserLoginModel>().Result : null;
                //ObjViewSubCategoryModel = objBLSubCategory.GetSubCategoryList(ObjViewSubCategoryModel);
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "UserList", "View GET");
            }
            return(View("ViewUserList", ObjViewUserLoginModel));
        }
예제 #7
0
        public ActionResult SaveCoupen(CoupenModel objCoupenModel)
        {
            try
            {
                objCoupenModel.IsActive  = true;
                objCoupenModel.CreatedBy = LoggedInUserID;

                //Insert or Update  Coupen
                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Coupen + "/InsertUpdateCoupen", objCoupenModel);
                objCoupenModel  = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <CoupenModel>().Result : null;

                //if error code is 0 means  Coupen saved successfully
                if (Convert.ToInt32(objCoupenModel.ErrorCode) == 0)
                {
                    // Set success message
                    TempData["SucessMessage"] = "Coupen Saved Successfully";
                    return(RedirectToAction("ViewCoupen", "Coupen"));
                }
                else if (Convert.ToInt32(objCoupenModel.ErrorCode) == 52)
                {
                    //If Errorcode is  52 means Coupen Name is duplicate set duplicate Coupen error message.
                    objCoupenModel.Message     = "Coupen Duplicate not allowed";
                    objCoupenModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();
                }
                else
                {
                    //set Error Message if error code is greater than 0 but not 52 (duplicate)
                    objCoupenModel.Message     = "Error while adding record";
                    objCoupenModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "Coupen", "SaveCoupen POST");
            }
            return(View("SaveCoupen", objCoupenModel));
        }
        public ActionResult ForgotPassword(ChangePasswordModel objChangePasswordModel)
        {
            UtilityWeb objUtilityWeb = new UtilityWeb();

            try
            {
                UserLogin     objUserLogin     = new RepidShare.Entities.UserLogin();
                EmailTemplate objEmailTemplate = new EmailTemplate();
                objUserLogin.Email = objChangePasswordModel.EmailID;
                serviceResponse    = objUtilityWeb.PostAsJsonAsync(WebApiURL.UserLogin + "/ForgotPassword", objUserLogin);
                objUserLogin       = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <UserLogin>().Result : null;
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(objChangePasswordModel.EmailID);
                serviceResponse  = objUtilityWeb.GetAsync(WebApiURL.Email + "/GetEmailSettingByEmailID?EmailID=" + Convert.ToInt32(RepidShare.Utility.CommonUtils.EmailType.ForgotPassword));
                objEmailTemplate = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <EmailTemplate>().Result : null;
                message.Subject  = objEmailTemplate.EmailSubject;
                //"Forgot Password By Papeleslegales.com";
                message.Body = objEmailTemplate.Content + "<br/>Your Password According to our records is: , <h3>" + objUserLogin.Password + "</h3>";;
                //"<p>Your password has been reset, <h3> " + objUserLogin.UserName + "</h3></p>  </br><p> According to our records, you have requested that your password be reset. Your new password is:<h3>" + objUserLogin.Password + "<h3/></p> </br></br><p>If you have any questions or trouble logging on please contact a site administrator.</p><br/><br/><br/>Thank you!";
                message.IsBodyHtml = true;

                if (objUserLogin.ErrorCode == 0)
                {
                    if (RepidShare.Utility.CommonUtils.Send(message))
                    {
                        // Session["SuccessMessage"] = "E-Mail Sent Successfully!";
                        objChangePasswordModel.Message = "<p style='color:green;'>Your Passowrd has been sent to your account. for login click <a href='http://localhost:49339/User/Login'> Login <a></p>";
                    }
                }
                else
                {
                    //  Session["ErrorMessage"] = "Oppps, Your Account is not valid!!!";
                    objChangePasswordModel.Message = "<p style='color:red;'>Oppps, Your Account is not valid!!!</p>";
                }

                // return RedirectToAction("Login", "User");
                return(View("ForgotPassword", objChangePasswordModel));
            }
            catch (Exception ex)
            {
                //Session["ExceptionMsg"] = objCommonUtils.ErrorLog(createdBy.ToString(), "User", "ForgotPassword Post", ex);
            }

            return(View("ForgotPassword", objChangePasswordModel));
        }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            UserLogin  objUserLogin  = new UserLogin();
            UtilityWeb objUtilityWeb = new UtilityWeb();

            objUserLogin.UserName = model.UserName;
            objUserLogin.Password = model.Password;

            if (ModelState.IsValid)
            {
                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.UserLogin + "/UserLogin", objUserLogin);
                objUserLogin    = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <UserLogin>().Result : null;

                if (objUserLogin == null)
                {
                    ModelState.AddModelError("", "Please contact with Admin");
                    return(View(model));
                }

                if (objUserLogin.ErrorCode > 0)
                {
                    ModelState.AddModelError("", "Invalid UserName Or Password");
                    return(View(model));
                }

                CommonUtils objCommonUtils = new CommonUtils();
                objCommonUtils.UserLoginDetails(objUserLogin);
                if (objUserLogin.RoleID == 1)
                {
                    return(Redirect(RepidShare.Utility.CommonUtils.AdminURL));
                }
                if (objUserLogin.RoleID == 2)
                {
                    return(RedirectToAction(returnUrl));
                }
                return(RedirectToLocal(returnUrl));
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(model));
        }
예제 #10
0
        public ActionResult ChangePassword(ChangePasswordModel objChangePasswordModel)
        {
            try
            {
                UtilityWeb objUtilityWeb = new UtilityWeb();
                UserLogin  objUserLogin  = new RepidShare.Entities.UserLogin();
                objUserLogin.UserID   = LoggedInUserID;
                objUserLogin.Password = objChangePasswordModel.ConfirmPassword;
                objUserLogin.RoleID   = RoleID;

                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.UserLogin + "/ChangePassword", objUserLogin);
                objUserLogin    = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <UserLogin>().Result : null;

                if (objUserLogin == null)
                {
                    //Set Error msg
                    objChangePasswordModel.Message     = "Please contact with Admin";
                    objChangePasswordModel.MessageType = RepidShare.Utility.CommonUtils.MessageType.Error.ToString().ToLower();
                }

                if (objUserLogin.ErrorCode > 0)
                {
                    objChangePasswordModel.Message     = "Invalid UserName Or Password";
                    objChangePasswordModel.MessageType = RepidShare.Utility.CommonUtils.MessageType.Error.ToString().ToLower();
                }

                if (objUserLogin.ErrorCode == 0)
                {
                    objChangePasswordModel.Message     = "Password changed successfully.";
                    objChangePasswordModel.MessageType = RepidShare.Utility.CommonUtils.MessageType.Success.ToString().ToLower();
                }
                return(View(objChangePasswordModel));
            }
            catch (Exception ex)
            {
                //  Session["ExceptionMsg"] = objCommonUtils.ErrorLog(createdBy.ToString(), "User", "ChangePassword Post", ex);
            }

            return(View(objChangePasswordModel));
        }
예제 #11
0
        public ActionResult Login(UserLogin objUserLogin)
        {
            UtilityWeb objUtilityWeb = new UtilityWeb();

            try
            {
                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.UserLogin + "/UserLogin", objUserLogin);
                objUserLogin    = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <UserLogin>().Result : null;

                if (objUserLogin == null)
                {
                    //Set Error msg
                    objUserLogin.Message     = "Please contact with Admin";
                    objUserLogin.MessageType = RepidShare.Utility.CommonUtils.MessageType.Error.ToString().ToLower();
                    //ModelState.AddModelError("", "Please contact with Admin");
                    return(View(objUserLogin));
                }

                if (objUserLogin.ErrorCode > 0)
                {
                    objUserLogin.Message     = "Invalid UserName Or Password";
                    objUserLogin.MessageType = RepidShare.Utility.CommonUtils.MessageType.Error.ToString().ToLower();
                    return(View(objUserLogin));
                }

                //Added By Rakesh
                Session["EmailId"]           = objUserLogin.Email;
                Session["RoleID"]            = objUserLogin.RoleID;
                Session["UserId"]            = objUserLogin.UserID;
                Session["UserFirstLastName"] = objUserLogin.FName + " " + objUserLogin.LName;

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                //  Session["ExceptionMsg"] = objCommonUtils.ErrorLog("0", "Account", "Login Post", ex);
            }
            return(RedirectToAction("Login", "User"));
        }
        /// <summary>
        /// Add or Edit Question for Document
        /// </summary>
        /// <param name="prm"></param>
        /// <returns></returns>
        public ActionResult SaveQuestion(string prm)
        {
            int DocumentId, DocumentQuestionId, StepID;
            ViewQuestionModel   objViewQuestionModel   = new ViewQuestionModel();
            QuestionDetailModel objQuestionDetailModel = new QuestionDetailModel();

            try
            {
                if (!String.IsNullOrEmpty(prm))
                {
                    string strPrm = CommonUtils.Decrypt(prm);
                    //If strPrm contain , means question is in edit mode else question is in add mode.
                    if (strPrm.Contains(",") && strPrm.Split(',').Length > 2)
                    {
                        int.TryParse(strPrm.Split(',')[0], out DocumentId);
                        int.TryParse(strPrm.Split(',')[1], out DocumentQuestionId);
                        int.TryParse(strPrm.Split(',')[2], out StepID);
                    }
                    else if (strPrm.Contains(",") && strPrm.Split(',').Length > 1)
                    {
                        int.TryParse(strPrm.Split(',')[0], out DocumentId);
                        int.TryParse(strPrm.Split(',')[1], out DocumentQuestionId);
                        StepID = 0;
                    }
                    else
                    {
                        int.TryParse(strPrm, out DocumentId);
                        //set DocumentQuestionId equal to 0 in case of Add Question.
                        DocumentQuestionId = 0;
                        StepID             = 0;
                    }
                    //if Document Id is 0 means some change in parameter. then set message Document not exist and redirect to view Document page.
                    if (DocumentId == 0)
                    {
                        TempData["NoticeMessage"] = "Document Not Exist";
                        return(RedirectToAction("ViewDocument", "Document"));
                    }

                    objQuestionDetailModel.DocumentID = DocumentId;
                    objQuestionDetailModel.QuestionID = DocumentQuestionId;
                    objQuestionDetailModel.StepID     = StepID;

                    //initial set of current page, pageSize , Total pages
                    objViewQuestionModel.CurrentPage = 1;
                    objViewQuestionModel.TotalPages  = 0;

                    objViewQuestionModel.QuestionDetail = objQuestionDetailModel;
                    //Get Question Type List to fill dropdown of Question Type
                    FillQuestionType();


                    if (StepID > 0)
                    {
                        objViewQuestionModel.PageSize = int.MaxValue - 1;
                        //ViewBag.ParentQuestionList
                        List <DropdownModel> objDropdown = new List <DropdownModel>();


                        List <DropdownModel> objParentSeSession = new List <DropdownModel>();
                        //Get Question in Add or Edit Model and also show Question List based on Document and sorting paging parameters
                        serviceResponse      = objUtilityWeb.PostAsJsonAsync(WebApiURL.Question + "/GetQuestions", objViewQuestionModel);
                        objViewQuestionModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewQuestionModel>().Result : null;
                        foreach (QuestionDetailModel objItem in objViewQuestionModel.QuestionsList)
                        {
                            DropdownModel objDropdownModel = new DropdownModel();
                            objDropdownModel.ID    = objItem.QuestionID;
                            objDropdownModel.Value = objItem.QuestionDescription;
                            if (objItem.QuestionType == CommonUtils.QuestionType.DropDown.ToString() || objItem.QuestionType == CommonUtils.QuestionType.SingleSelect.ToString())
                            {
                                objDropdown.Add(objDropdownModel);
                                objParentSeSession.Add(new DropdownModel {
                                    ID = objItem.QuestionID, Value = objItem.ParentDDLText
                                });
                            }
                        }

                        Session["ParentSeSession"] = null;
                        Session["ParentSeSession"] = objParentSeSession;

                        ViewBag.ParentQuestionList = new SelectList(objDropdown, "Id", "Value", objViewQuestionModel.QuestionDetail.ParentQuestion);
                        List <DropdownModel> objDropdownParent = new List <DropdownModel>();

                        if (Convert.ToInt32(objViewQuestionModel.QuestionDetail.ParentQuestion) > 0)
                        {
                            if (Session["ParentSeSession"] != null)
                            {
                                string       OptionText = objParentSeSession.Where(x => x.ID == Convert.ToInt32(objViewQuestionModel.QuestionDetail.ParentQuestion)).FirstOrDefault().Value;
                                StringReader theReader  = new StringReader("<XmlDS>" + OptionText + "</XmlDS>");
                                DataSet      theDataSet = new DataSet();
                                theDataSet.ReadXml(theReader);

                                foreach (DataRow item in theDataSet.Tables[0].Rows)
                                {
                                    if (item["Value"].ToString() == objViewQuestionModel.QuestionDetail.ParentAnswer.ToString())
                                    {
                                        objViewQuestionModel.QuestionDetail.ParentAnswer = item["ID"].ToString();
                                    }
                                    objDropdownParent.Add(new DropdownModel
                                    {
                                        ID    = Convert.ToInt32(item["ID"]),
                                        Value = item["Value"].ToString() //,
                                                                         //Selected = item["Value"].ToString() == objViewQuestionModel.QuestionDetail.ParentAnswer.ToString() ? true : false
                                    });
                                }
                            }
                        }
                        ViewBag.ParentAnswerList = new SelectList(objDropdownParent, "Id", "Value", objViewQuestionModel.QuestionDetail.ParentAnswer);

                        if (objViewQuestionModel.QuestionDetail.QuestionType == CommonUtils.QuestionType.DropDown.ToString())
                        {
                            DropDownValue(objViewQuestionModel.QuestionDetail.DropDownXML);
                        }
                    }
                    else
                    {
                        objViewQuestionModel.PageSize = CommonUtils.PageSize;
                        //Get Question in Add or Edit Model and also show Question List based on Document and sorting paging parameters
                        serviceResponse      = objUtilityWeb.PostAsJsonAsync(WebApiURL.Question + "/GetQuestions", objViewQuestionModel);
                        objViewQuestionModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewQuestionModel>().Result : null;
                    }


                    objViewQuestionModel.QuestionTypeDetail = new QuestionTypeDetailModel();
                    //if question is in edit mode than set Question properties based on quetion type
                    if (objViewQuestionModel != null && objViewQuestionModel.QuestionDetail != null && !String.IsNullOrEmpty(objViewQuestionModel.QuestionDetail.QuestionType))
                    {
                        objViewQuestionModel.QuestionTypeDetail = objCommonUtils.SetQuestionProperties(objViewQuestionModel.QuestionDetail.QuestionType, objViewQuestionModel.QuestionPropertyList, objViewQuestionModel.QuestionTypeDetail, objViewQuestionModel.QuestionDetail.QuestionOptionsList, objViewQuestionModel.QuestionDetail.DropDownXML);
                    }
                    //if Success Message is not null and empty means question save successfully than set Success Message
                    if (TempData["QuestionSucessMessage"] != null && Convert.ToString(TempData["QuestionSucessMessage"]) != "")
                    {
                        objViewQuestionModel.Message      = Convert.ToString(TempData["QuestionSucessMessage"]);
                        objViewQuestionModel.MessageType  = CommonUtils.MessageType.Success.ToString().ToLower();
                        TempData["QuestionSucessMessage"] = null;
                    }
                    else if (objViewQuestionModel.QuestionDetail.IsPublish && objViewQuestionModel.QuestionDetail.QuestionID <= 0)
                    {
                        objViewQuestionModel.Message     = "Can Not Edit Document";
                        objViewQuestionModel.MessageType = CommonUtils.MessageType.Notice.ToString().ToLower();
                    }

                    StepDropDown(objViewQuestionModel.QuestionDetail.StepID, objViewQuestionModel.QuestionDetail.DocumentID);
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "Question", "SaveQuestion Get");
            }
            return(View("SaveQuestion", objViewQuestionModel));
        }
        //[Filters.MenuAccess]
        public ActionResult ViewDocumentPreview(string prm)
        {
            //Object of Model.
            DocumentResponseDetailModel objDocumentDetailModel = new DocumentResponseDetailModel();

            try
            {
                int    DocumentID = 0;
                String PageName   = string.Empty;
                if (!String.IsNullOrEmpty(prm))
                {
                    //Decrypt query string
                    string inputParameter = CommonUtils.Decrypt(prm).ToString().Replace("?", "").ToLower();

                    //Get query string paramtere  and set value
                    // get Document id
                    if (inputParameter.IndexOf("Documentid") > -1)
                    {
                        foreach (var item in inputParameter.Split('&'))
                        {
                            if (item.IndexOf("Documentid") > -1)
                            {
                                int.TryParse(item.Replace("Documentid=", ""), out DocumentID);
                            }
                            // get page name where from this page url is open.
                            if (item.IndexOf("pagename") > -1)
                            {
                                PageName = Convert.ToString(item.Replace("pagename=", ""));
                            }
                        }
                    }
                }

                //check page name is null or blank then set by default url.
                if (string.IsNullOrWhiteSpace(PageName))
                {
                    objDocumentDetailModel.ReferralUrl = "/Document/ViewDocument";
                    //objDocumentDetailModel.UrlTitle = IIMSDocumentEntities.Resource.DocumentResource.lblViewDocument;//"View Document";
                }
                else if (string.IsNullOrWhiteSpace(objDocumentDetailModel.ReferralUrl))
                {
                    switch (PageName)
                    {
                    case "home":
                        objDocumentDetailModel.ReferralUrl = "/Home/Home";
                        objDocumentDetailModel.UrlTitle    = "Home";

                        break;

                    case "Documentuser":
                        objDocumentDetailModel.ReferralUrl = "/Document/viewDocumentuser?prm=" + CommonUtils.Encrypt(Convert.ToString(DocumentID));
                        //objDocumentDetailModel.UrlTitle = IIMSDocumentEntities.Resource.DocumentResource.lblViewDocumentUser;//"View Document User";
                        break;

                    default:
                        objDocumentDetailModel.ReferralUrl = "/Document/ViewDocument";
                        //objDocumentDetailModel.UrlTitle = IIMSDocumentEntities.Resource.DocumentResource.lblViewDocument;//"View Document";
                        break;
                    }
                }

                //Set default parameter
                objDocumentDetailModel.DocumentID = DocumentID;
                objDocumentDetailModel.IsReadOnly = false;
                //Get Document response detail model from database.

                serviceResponse        = objUtilityWeb.PostAsJsonAsync(WebApiURL.DocumentResponse + "/GetDocumentPreview", objDocumentDetailModel);
                objDocumentDetailModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <DocumentResponseDetailModel>().Result : null;

                //objDocumentDetailModel = objBLDocumentResponse.GetDocumentPreview(objDocumentDetailModel);

                switch (objDocumentDetailModel.ErrorCode)
                {
                case 61:
                    //Session["ResultNoticeMessage"] = IIMSDocumentEntities.Resource.DocumentResource.msgDocumentNotExist;
                    return(Redirect(objDocumentDetailModel.ReferralUrl));
                }
                if (objDocumentDetailModel != null && objDocumentDetailModel.Questions != null && objDocumentDetailModel.Questions.Count() > 0)
                {
                    CommonUtils objCommonUtils = new CommonUtils();
                    //set question type detail for questions
                    foreach (ViewQuestionAnswerModel objViewQuestionAnswerModel in objDocumentDetailModel.Questions)
                    {
                        objViewQuestionAnswerModel.QuestionTypeDetail = new QuestionTypeDetailModel();
                        if (!String.IsNullOrEmpty(objViewQuestionAnswerModel.QuestionType))
                        {
                            objViewQuestionAnswerModel.QuestionTypeDetail = objCommonUtils.SetQuestionProperties(objViewQuestionAnswerModel.QuestionType, objViewQuestionAnswerModel.QuestionPropertyList, objViewQuestionAnswerModel.QuestionTypeDetail, objViewQuestionAnswerModel.QuestionOptionsList);
                        }
                    }
                }
            }
            //handle exception and set error message and log.
            catch (Exception ex)
            {
                ErrorLog(ex, "DocumentResponse", "ViewDocumentPreview GET");
                //objDocumentDetailModel.Message = String.Format(DocumentResponse.msgViewDocumentError, "View Document Preview");
                objDocumentDetailModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();
            }
            //return view
            return(View(objDocumentDetailModel));
        }
        private Payment CreatePayment(APIContext apiContext, string redirectUrl)
        {
            if (Session["PayPalItemDetail"] != null)
            {
                PayPalItemDetail objPayPalItemDetail = (PayPalItemDetail)Session["PayPalItemDetail"];

                //similar to credit card create itemlist and add item objects to it

                //var itemList = objPayPalItemDetail.itemList;

                var itemList = new ItemList()
                {
                    items = new List <Item>()
                };

                for (int i = 0; i < objPayPalItemDetail.itemList.items.Count; i++)
                {
                    itemList.items.Add(new Item()
                    {
                        url      = objPayPalItemDetail.itemList.items[i].url.ToString(),
                        name     = objPayPalItemDetail.itemList.items[i].name,
                        currency = "USD",
                        price    = objPayPalItemDetail.itemList.items[i].price,
                        quantity = "1",
                        sku      = "sku",
                        tax      = objPayPalItemDetail.itemList.items[i].tax.ToString()
                    });
                }


                var payer = new Payer()
                {
                    payment_method = "paypal"
                };

                // Configure Redirect Urls here with RedirectUrls object
                var redirUrls = new RedirectUrls()
                {
                    cancel_url = redirectUrl,
                    return_url = redirectUrl
                };

                // similar as we did for credit card, do here and create details object
                //var details = objPayPalItemDetail.details;

                double sumAmt = 0;
                foreach (Item item in objPayPalItemDetail.itemList.items)
                {
                    sumAmt += Convert.ToDouble(item.price);
                }

                double sumVat = 0;
                foreach (Item item in objPayPalItemDetail.itemList.items)
                {
                    sumVat += Convert.ToDouble(item.tax);
                }

                var details = new Details()
                {
                    tax      = sumVat.ToString(),
                    shipping = "0",
                    subtotal = sumAmt.ToString()
                };

                //vat tax
                sumAmt = sumAmt + sumVat;

                //shippiing
                sumAmt = sumAmt + 0;

                var amount = new Amount()
                {
                    currency = "USD",
                    total    = sumAmt.ToString(), // Total must be equal to sum of shipping, tax and subtotal.
                    details  = objPayPalItemDetail.details
                };

                var transactionList = new List <Transaction>();

                transactionList.Add(new Transaction()
                {
                    description    = "Transaction description.",
                    invoice_number = "your invoice number",
                    amount         = amount,
                    item_list      = itemList
                });

                this.payment = new Payment()
                {
                    intent        = "sale",
                    payer         = payer,
                    transactions  = transactionList,
                    redirect_urls = redirUrls
                };



                OdersModel objOdersModel = new OdersModel();

                objOdersModel.OrderDate            = DateTime.Now;
                objOdersModel.OrderID              = 0;
                objOdersModel.PaidTotal            = Convert.ToDecimal(objPayPalItemDetail.amount.total);
                objOdersModel.PaymentID            = 0;
                objOdersModel.RefTimestamp         = Convert.ToString(DateTime.Now.ToString("ddmmyyyyhhmmsss"));;
                objOdersModel.TransactStatus       = "In Progress";
                objOdersModel.UserId               = LoggedInUserID;
                objOdersModel.OdersDetailModelList = new List <OdersDetailModel>();

                for (int i = 0; i < objPayPalItemDetail.itemList.items.Count; i++)
                {
                    objOdersModel.OdersDetailModelList.Add(new OdersDetailModel {
                        Discount = 0, DocumentID = Convert.ToInt32(objPayPalItemDetail.itemList.items[i].url), Price = Convert.ToDecimal(objPayPalItemDetail.itemList.items[i].price), Quantity = 1, Total = Convert.ToDecimal(objPayPalItemDetail.itemList.items[i].price), VatTax = Convert.ToDecimal(objPayPalItemDetail.itemList.items[i].tax)
                    });
                }

                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Order + "/InsertUpdateOrder", objOdersModel);
                objOdersModel   = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <OdersModel>().Result : null;


                // Create a payment using a APIContext
                return(this.payment.Create(apiContext));
            }
            else
            {
                return(null);
            }
        }