Skip to content

Feature request: Possibility to delete record from AFASΒ #7

Open
@Avdeev99

Description

Hi,

I was wondering if it is possible to add methods to delete records from AFAS, such as Delete and DeleteAsync.

I think the implementation could be the same as for SaveAsync and UpdateAsync, just using HTTP DELETE method:

public async Task<UpdateResult<TResult>> DeleteAsync<TResult>(
      IUpdateable<TResult> value,
      string subitem = "")
    {
      GeneralBase generalBase = this;
      string payload = AfasUpdateWriter.Write((IUpdateEntity) value, new IUpdateEntity[1]
      {
        (IUpdateEntity) value
      });
      string str1 = ConnectorNameAttribute.GetConnectorName<IUpdateable<TResult>>(value);
      if (generalBase is RefineryClient)
        str1 = str1.Replace("Tafas", "Pocket");
      string urlPath = "connectors/" + str1;
      if (subitem != "")
        urlPath = urlPath + "/" + subitem;
      HttpResponseMessage res = await generalBase.SendAuthHttp(urlPath, payload, HttpMethod.Delete);
      string str2 = await res.Content.ReadAsStringAsync();
      UpdateResult<TResult> updateResult = res.IsSuccessStatusCode ? UpdateResult<TResult>.CreateSuccess(str2) : UpdateResult<TResult>.CreateError(str2);
      res = (HttpResponseMessage) null;
      return updateResult;
    }

It would be really useful for integration with AFAS and also implementing integration tests.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions