Ejemplo n.º 1
0
 public AdminParticipantListViewModel AdminApiModelToVM(AdminParticipantModel admin)
 {
     return(new AdminParticipantListViewModel
     {
         ID = admin.ID,
         Name = admin.Name
     });
 }
Ejemplo n.º 2
0
        private string ReturnApiJsonForSearchByAdmin(AdminParticipantModel adminParticipant)
        {
            /*
             *  {"where": {"contractProvider": "resource:org.example.basic.HubAdmin#f874d863-aba7-448c-965f-f174cb80c01b"}}
             */

            var jsonObj = (new[] { adminParticipant }).Select(x =>
            {
                var xObj =
                    new Newtonsoft.Json.Linq.JObject(
                        new Newtonsoft.Json.Linq.JProperty("where", new Newtonsoft.Json.Linq.JObject(
                                                               new Newtonsoft.Json.Linq.JProperty("contractProvider", $"resource:{GetFullResource(x._Class, x.ID)}")
                                                               ))
                        );

                return(xObj);
            }).First();

            string json = JsonConvert.SerializeObject(jsonObj, Formatting.Indented);

            return(json);
        }
Ejemplo n.º 3
0
 public async Task <(bool, string)> Update(AdminParticipantModel participantData)
 {
     return(await base.Update(participantData));
 }
Ejemplo n.º 4
0
        public async Task <(bool, string, IEnumerable <RentContractModelResponse>)> GetAllForAdmin(AdminParticipantModel adminParticipant)
        {
            var success      = true;
            var errorMsg     = string.Empty;
            var contractList = new List <RentContractModelResponse>().AsEnumerable();

            try
            {
                var jsonContent = ReturnApiJsonForSearchByAdmin(adminParticipant);
                var urlEncoded  = $"{ApiUrl}?filter={HttpUtility.UrlEncode(jsonContent)}";
                var response    = await SendRequestAsync <IEnumerable <RentContractModelResponse> >(RequestType.Get, urlEncoded);

                LogHelper.Info(Logger, $"{nameof(GetAllForAdmin)} - success: {response.Success} - message: {response.Message}");

                if (!response.Success)
                {
                    throw new Exception(response.Message);
                }
                else if (response.ResponseObj?.Count() > 0)
                {
                    contractList = response.ResponseObj;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Exception(Logger, $"{nameof(GetAllForAdmin)} Exception", ex);
                errorMsg = ex.Message;
                success  = false;
            }

            return(success, errorMsg, contractList);
        }