public HttpResponseMessage Delete()
        {
            bal = new T_Planing_Action_SitePreparationBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_SitePreparationDTO dto = null;

            try
            {
                var context = HttpContext.Current;
                //context.Response.ContentType = "multipart/form-data";

                dto = ConvertX.GetReqeustForm <T_Planing_Action_SitePreparationDTO>();

                logger.debug("Delete dto :" + dto.ToString());

                bal.Delete(dto);

                response.statusCode = true;
                response.data       = "Delete success";
            }
            catch (Exception ex)
            {
                logger.error("Delete error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
        public HttpResponseMessage SearchAllUndergrounds()
        {
            bal = new T_Planing_Action_SitePreparationBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_SitePreparationDTO dto     = null;
            List <M_UndergroundDTO>             objList = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_SitePreparationDTO>();

                logger.debug("PlanActionSitePreparationController SearchAllUndergrounds dto:" + dto.ToString());
                objList = bal.FindAllUndergrounds(dto);

                response.statusCode = true;
                response.data       = objList;
            }
            catch (Exception ex)
            {
                logger.error("PlanActionSitePreparationController SearchAllUndergrounds error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
        public HttpResponseMessage Search()
        {
            var deserializer = new JavaScriptSerializer();

            bal = new T_Planing_Action_SitePreparationBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_SitePreparationDTO        dto     = null;
            List <T_Planing_Action_SitePreparationDTO> objList = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_SitePreparationDTO>();

                logger.debug("Search dto :" + dto.ToString());
                objList = bal.FindByObjList(dto);

                foreach (T_Planing_Action_SitePreparationDTO mainDTO in objList)
                {
                    //Find detail and push to main object in list
                    T_Planing_Action_SitePreparationDTO detailDTO = new T_Planing_Action_SitePreparationDTO();
                    detailDTO.PID = mainDTO.PID;
                    detailDTO     = bal.FindByPK(detailDTO);

                    mainDTO.UploadFileList = detailDTO.UploadFileList;

                    if (!ObjUtil.isEmpty(mainDTO.UploadFileList))
                    {
                        foreach (T_Planing_File file in mainDTO.UploadFileList)
                        {
                            file.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + file.PID + "/" + file.UploadType + "/" + file.FileName);
                            string fullPath = context.Server.MapPath(planPath) + @"\" + file.PID + @"\" + file.UploadType + @"\" + file.FileName;
                            file.Base64File = Utility.convertFileToBase64(fullPath);
                        }
                    }
                }

                response.statusCode = true;
                response.data       = objList;
            }
            catch (Exception ex)
            {
                logger.error("Search error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
        public HttpResponseMessage SearchAllFiles()
        {
            bal = new T_Planing_Action_SitePreparationBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_SitePreparationDTO dto = null;
            List <T_Planing_File> objList           = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_SitePreparationDTO>();

                logger.debug("PlanActionSitePreparationController SearchAllFiles dto:" + dto.ToString());
                objList = bal.FindAllFiles(dto);

                if (!ObjUtil.isEmpty(objList))
                {
                    foreach (T_Planing_File file in objList)
                    {
                        file.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + file.PID + "/" + file.UploadType + "/" + file.FileName);
                        string fullPath = context.Server.MapPath(planPath) + @"\" + file.PID + @"\" + file.UploadType + @"\" + file.FileName;
                        file.Base64File = Utility.convertFileToBase64(fullPath);
                    }
                }

                response.statusCode = true;
                response.data       = objList;
            }
            catch (Exception ex)
            {
                logger.error("PlanActionSitePreparationController SearchAllFiles error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
        public HttpResponseMessage View()
        {
            var deserializer = new JavaScriptSerializer();

            bal = new T_Planing_Action_SitePreparationBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_SitePreparationDTO dto = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_SitePreparationDTO>();

                logger.debug("View dto :" + dto.ToString());
                dto = bal.FindByPK(dto);

                if (dto != null && dto.UploadFileList != null)
                {
                    foreach (var uploadFile in dto.UploadFileList)
                    {
                        uploadFile.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + dto.PID + "/" + uploadFile.UploadType + "/" + uploadFile.FileName);
                        string fullPath = context.Server.MapPath(planPath) + @"\" + uploadFile.PID + @"\" + uploadFile.UploadType + @"\" + uploadFile.FileName;
                        uploadFile.Base64File = Utility.convertFileToBase64(fullPath);
                    }
                }
                response.statusCode = true;
                response.data       = dto;
            }
            catch (Exception ex)
            {
                logger.error("View error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }