Example #1
0
        public async Task <ActionResult> EditProject(int projectID)
        {
            ProjectModel model = new ProjectModel();

            ProjectBE project = FormLogic.FetchProject(projectID);

            if (Functions.IsNull(project))
            {
                project = new ProjectBE();
            }
            BusinessEntityHelper.ConvertBEToBEForUI <ProjectBE, ProjectModel>(project, model);
            using (var httpClient = new HttpClient())
            {
                string url = DBConfiguration.WebAPIHostingURL;
                if (!string.IsNullOrWhiteSpace(url))
                {
                    string webAPIURL = string.Empty;

                    webAPIURL = string.Format("{0}form/GetForms", url);

                    using (var response = await httpClient.GetAsync(webAPIURL))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        List <SelectListItem> forms = JsonConvert.DeserializeObject <List <SelectListItem> >(apiResponse);
                        ViewData["FormList"] = forms;
                    }

                    webAPIURL = string.Format("{0}project/GetClient", url);

                    using (var response = await httpClient.GetAsync(webAPIURL))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        List <SelectListItem> client = JsonConvert.DeserializeObject <List <SelectListItem> >(apiResponse);
                        ViewData["ClientList"] = client;
                    }
                }
            }
            List <ProjectFormBE> list = FormLogic.BlockFetchProjectForm(projectID, 1, int.MaxValue, out int totalRecords);

            if (list != null)
            {
                model.ProjectFormList = list.Select(m => m.FormId).ToList();
            }


            return(View(model));
        }