Пример #1
0
        public JsonResult DeleteDocumentDetails(int acid, int nDocumentDetailsID, string sGUID, int nMapToTypeCodeId = 0, int nMapToId = 0, int nPurposeCodeId = 0)
        {
            bool bReturn         = false;
            bool statusFlag      = false;
            var  ErrorDictionary = new Dictionary <string, string>();

            LoginUserDetails objLoginUserDetails = null;

            try
            {
                objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);

                using (DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL())
                {
                    bReturn = objDocumentDetailsSL.DeleteDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, nDocumentDetailsID, objLoginUserDetails.LoggedInUserID, nMapToTypeCodeId, nMapToId, nPurposeCodeId);
                    if (bReturn)
                    {
                        string   directory = ConfigurationManager.AppSettings["Document"];
                        FileInfo file      = new FileInfo(Path.Combine(directory, nMapToTypeCodeId.ToString(), nMapToId.ToString(), sGUID));
                        file.Delete();
                        statusFlag = true;
                        ErrorDictionary.Add("success", "Record deleted");
                    }
                }
            }
            catch (Exception exp)
            {
                ModelState.Remove("KEY");
                ModelState.Add("KEY", new ModelState());
                ModelState.Clear();
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("error", sErrMessage);
            }
            finally
            {
                objLoginUserDetails = null;
            }

            return(Json(new
            {
                status = statusFlag,
                Message = ErrorDictionary
            }, "text/html"));
        }
Пример #2
0
        public JsonResult DeleteSingleDocumentDetails(int?nDocumentDetailsID, int nIndex, int nSubIndex, string GUID, int acid, int nMapToTypeCodeId = 0, int nMapToId = 0, int nPurposeCodeId = 0)
        {
            bool             bReturn             = false;
            bool             statusFlag          = false;
            bool             userType            = false;
            var              ErrorDictionary     = new Dictionary <string, string>();
            bool             removeMapToId       = true;
            LoginUserDetails objLoginUserDetails = null;
            Dictionary <string, DocumentDetailsDTO> dicDocumentDetailsDTO = null;

            try
            {
                objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
                //  DocumentDetailsDTO objDocumentDetailsDTO = new DocumentDetailsDTO();
                string directory = ConfigurationManager.AppSettings["Document"];
                if (nDocumentDetailsID != null && nDocumentDetailsID != 0)
                {
                    if (nMapToTypeCodeId == ConstEnum.Code.UserDocument)
                    {
                        userType = true;
                    }
                    if (acid == InsiderTrading.Common.ConstEnum.UserActions.COMPANY_VIEW)
                    {
                        removeMapToId = false;
                    }
                    using (DocumentDetailsSL objDocumentDetailsSL = new DocumentDetailsSL())
                    {
                        bReturn = objDocumentDetailsSL.DeleteDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, Convert.ToInt32(nDocumentDetailsID), objLoginUserDetails.LoggedInUserID, nMapToTypeCodeId, nMapToId, Convert.ToInt32(nPurposeCodeId));
                        if (bReturn)
                        {
                            if (nMapToTypeCodeId != Common.ConstEnum.Code.TradingPolicy)
                            {
                                if (System.IO.File.Exists(Path.Combine(directory, nMapToTypeCodeId.ToString(), nMapToId.ToString(), GUID)))
                                {
                                    FileInfo file = new FileInfo(Path.Combine(directory, nMapToTypeCodeId.ToString(), nMapToId.ToString(), GUID));
                                    file.Delete();
                                }
                            }
                            statusFlag = true;
                            ErrorDictionary.Add("Document", "Record deleted");
                        }
                    }
                }
                else
                {
                    dicDocumentDetailsDTO = objLoginUserDetails.DocumentDetails;
                    if (dicDocumentDetailsDTO != null && dicDocumentDetailsDTO.Count > 0 && dicDocumentDetailsDTO.ContainsKey(GUID))
                    {
                        if (System.IO.File.Exists(Path.Combine(directory, "temp", GUID)))
                        {
                            FileInfo file = new FileInfo(Path.Combine(directory, "temp", GUID));
                            file.Delete();
                        }
                        objLoginUserDetails.DocumentDetails.Remove(GUID);
                        Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails);
                        statusFlag = true;
                        ErrorDictionary.Add("Document", "Record deleted");
                    }
                }
            }
            catch (Exception exp)
            {
                ModelState.Remove("KEY");
                ModelState.Add("KEY", new ModelState());
                ModelState.Clear();
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("Document", sErrMessage);
            }
            finally
            {
                objLoginUserDetails   = null;
                dicDocumentDetailsDTO = null;
            }

            return(Json(new
            {
                status = statusFlag,
                Message = ErrorDictionary,
                Index = nIndex,
                SubIndex = nSubIndex,
                userType = userType,
                removeMapToId = removeMapToId
            }, "text/html"));
        }