コード例 #1
0
        public ActionResult UploadLogo(FormCollection frmcol, HttpPostedFileBase fleUpload)
        {
            objDCClientInfo                = new DCClientInfo();
            objBLClientInfo                = new BLClientInfo();
            objDCUsers                     = (DCUsers)Session["UserLogon"];
            objDataOperationResponse       = new DataOperationResponse();
            objDCClientInfo.UserId         = objDCUsers.UserId;
            objDCClientInfo.ClientUploadId = string.IsNullOrEmpty(frmcol["hdnClientUploadId"]) ? 0 : Convert.ToInt32(frmcol["hdnClientUploadId"]);
            objDCClientInfo.Description    = frmcol["txtDescription"];
            if (frmcol["btnLogoSave"] == "Save")
            {
                objDCClientInfo.FileType = "Logo";
            }
            else
            {
                objDCClientInfo.FileType = "Document";
            }
            if (fleUpload != null && fleUpload.ContentLength > 0)
            {
                //Save to folder
                string UniqueFileName  = Guid.NewGuid() + "-" + Path.GetFileName(fleUpload.FileName);
                string path            = Path.Combine(Server.MapPath("~/Uploads/LogoUpload/"), UniqueFileName);
                var    FileVirtualPath = "/Uploads/LogoUpload/" + UniqueFileName;
                fleUpload.SaveAs(path);
                //Save to database

                objDCClientInfo.UploadLogo = FileVirtualPath;
            }
            objDataOperationResponse = objBLClientInfo.UploadLogo(objDCClientInfo);
            TempData["activetab"]    = "2";
            if (objDataOperationResponse.Code > 0)
            {
                TempData["successMessage"] = objDataOperationResponse.Message;
                return(RedirectToAction("AddUpdateClientInfo"));
            }
            else
            {
                TempData["errorMessage"] = objDataOperationResponse.Message;
                return(RedirectToAction("AddUpdateClientInfo"));
            }
        }