Пример #1
0
        public async Task GetExcludeDirectory(HttpSessionStateBase currentSession, string id, int credid)
        {
            objDataSetIndexCredExcludeView = new DataSetIndexCredExcludeView();

            string        accessToken   = UserSession.accessToken(currentSession);
            HttpGetObject objHttpObject = new HttpGetObject();

            objHttpObject.accessToken = accessToken;
            objHttpObject.id          = Convert.ToString(credid);
            objHttpObject.endPoint    = EndPointExcludeDirectory;
            APIClient           apiclient = new APIClient();
            HttpResponseMessage dsResp    = await apiclient.getAsync(objHttpObject);

            if (!dsResp.IsSuccessStatusCode)
            {
                errorOccurred = true;
            }
            else
            {
                string val = await dsResp.Content.ReadAsStringAsync();

                objDataSetIndexCredExcludeViewlist = JsonConvert.DeserializeObject <List <DataSetIndexCredExcludeView> >(val);
                objDataSetIndexCredExcludeDirPatch = new DataSetIndexCredExcludeDirPatch();
                foreach (DataSetIndexCredExcludeView resp in objDataSetIndexCredExcludeViewlist)
                {
                    if (resp.id == Convert.ToInt32(id))
                    {
                        objDataSetIndexCredExcludeDirPatch.directoryExclude = resp.directoryExclude;
                        break;
                    }
                }
            }
        }
        public async Task <ActionResult> Patch(DataSetIndexCredExcludeDirPatch obj, string id, string dataSetIndexId, string dataSetId, int credId)
        {
            ExcludeDirectoryViewModel viewmodel = new ExcludeDirectoryViewModel();

            viewmodel.objDataSetIndexCredExcludeDirPatch = new DataSetIndexCredExcludeDirPatch();
            viewmodel.objDataSetIndexCredExcludeDirPatch.directoryExclude = obj.directoryExclude;

            if (!ModelState.IsValid)
            {
                return(View(viewmodel));
            }

            await viewmodel.EditExcludeDirectory(Session, id);

            if (viewmodel.errorOccurred == true)
            {
                viewmodel.ErrorMessage = "Something wrong please try again.";
                return(View(viewmodel));
            }
            viewmodel.ErrorMessage = "Data save successfully.";
            return(Redirect("/ExcludeDirectory/Index?credId=" + credId + "&dataSetIndexId=" + dataSetIndexId + "&dataSetId=" + dataSetId));
        }