示例#1
0
    public IEnumerable <CashValueUI> GetCashValuesByPolicy([FromUri] PoliciesFilter filter)
    {
        ProfileCommon profile = APIhelper.GetProfileCommon(Request);
        web_Company   wc      = DB.GetCompanyByID(profile.CompanyID);

        return(CashValueUI.GetCashValuesByPolicy(profile, wc, filter));
    }
示例#2
0
    public IHttpActionResult GetDownload(string id)
    {
        IHttpActionResult result  = null;
        ProfileCommon     profile = APIhelper.GetProfileCommon(Request);

        if (!string.IsNullOrEmpty(id))
        {
            web_Document doc = GetWebDocument(id);

            if (doc != null)
            {
                string file = Path.Combine(Util.GetAppSettings("DocRoot") + doc.Path);

                var fileinfo = new FileInfo(file);
                try
                {
                    if (!fileinfo.Exists)
                    {
                        throw new FileNotFoundException(fileinfo.Name);
                    }

                    result = new FileActionResult(file);
                }
                catch (Exception ex)
                {
                    result = ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "File not found"));
                }
            }
        }

        return(result);
    }
示例#3
0
    public IEnumerable <PremiumListUI> GetPremiumsByCompanyUI([FromUri] string id)
    {
        ProfileCommon profile   = APIhelper.GetProfileCommon(Request);
        int           companyId = DB.GetBorrowerClientCompanyId(profile, id);

        return(PremiumListUI.GetPremiumsByCompanyUI(companyId, profile, id));
    }
示例#4
0
    public DocumentUI GetDocument([FromUri] DocumentsFilter filter)
    {
        ProfileCommon profile   = APIhelper.GetProfileCommon(Request);
        int           companyId = DB.GetBorrowerClientCompanyId(profile, filter.BorrowerId);

        return(DocumentUI.GetDocument(companyId, filter.DocumentId));
    }
示例#5
0
    private IEnumerable <DocumentUI> GetDocumentsByCompany(DocumentsFilter filter)
    {
        ProfileCommon profile = APIhelper.GetProfileCommon(Request);
        web_Company   wc      = DB.GetCompanyByID(profile.CompanyID);

        return(DocumentUI.GetDocumentsByCompanyUI(profile,
                                                  wc,
                                                  filter.BorrowerId,
                                                  filter.FileType));
    }
示例#6
0
    public IEnumerable <string> GetDocumentConfigs(int id)
    {
        ProfileCommon profile = APIhelper.GetProfileCommon(Request);

        if (Security.IsAdmin(profile) || Security.IsSuperAdmin(profile))
        {
            return(DB.GetDocumentConfigsByCompanyId(id));
        }
        else
        {
            return(new List <string>());
        }
    }
示例#7
0
    public HttpResponseMessage Download(string documentID)
    {
        Log.LogSubType subType = Log.LogSubType.DocumentIDInvalid;
        ProfileCommon  profile = APIhelper.GetProfileCommon(Request);
        bool           error   = true;

        if (!string.IsNullOrEmpty(documentID))
        {
            web_Document doc = GetWebDocument(documentID);

            if (doc != null)
            {
                string file = Path.Combine(Util.GetAppSettings("DocRoot") + doc.Path);

                if (File.Exists(file))

                {
                    var response = new HttpResponseMessage(HttpStatusCode.OK);
                    var stream   = new FileStream(file, FileMode.Open);
                    var fileInfo = new FileInfo(file);
                    response.Content = new StreamContent(stream);
                    response.Content.Headers.ContentLength      = stream.Length;
                    response.Content.Headers.ContentType        = new MediaTypeHeaderValue(Util.GetMimeTypeFromExtension(fileInfo.Extension));
                    response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                    {
                        FileName = fileInfo.Name
                    };

                    return(response);
                }
                else
                {
                    subType = Log.LogSubType.DocumentNotFound;
                    Log.WriteLog(Log.LogType.Exception, User.Identity.Name, subType, documentID, file, null);
                }
            }
            else
            {
                subType = Log.LogSubType.DocumentRecordMissing;
                Log.WriteLog(Log.LogType.Exception, profile.UserName, subType, documentID, null, null);
            }
        }

        if (error)
        {
            Log.WriteLog(Log.LogType.Exception, profile.UserName, subType, documentID, null, null);
        }

        return(new HttpResponseMessage(HttpStatusCode.OK));
    }
示例#8
0
    private web_Document GetWebDocument(string id)
    {
        web_Document  doc     = null;
        ProfileCommon profile = APIhelper.GetProfileCommon(Request);

        using (PolicyDataSourceDataContext db = new PolicyDataSourceDataContext())
        {
            db.ObjectTrackingEnabled = false;
            doc = (from d in db.web_Documents
                   where d.DocumentID == id &&
                   (d.CompanyID == profile.CompanyID)
                   select d).FirstOrDefault();
        }

        return(doc);
    }
示例#9
0
    public IEnumerable <PremiumListUI> GetByPolicyUI([FromUri] PoliciesFilter filter)
    {
        ProfileCommon profile = APIhelper.GetProfileCommon(Request);

        return(PremiumListUI.GetPremiumsByPolicyUI(profile, filter));
    }