Contents tagged with Web Api

  • Making post to Web Api Controller.

    Hello everybody,

    today I want to share with you one small note, how to make post of some js object to controller.

    So, let's say you have following class:

    public class SomeClass : MongoEntityBase

        {

            public ObjectId TenderId { get; set; }

            public int RectificationNumber { get; set; }

            public RectificationReason RectificationReason { get; set; }

            public string RectificationText { get; set; }

        }

    And some method in your web api controller:

    [AllowAnonymous, HttpGet, HttpPost, Route("create")]

    public async Task<SomeClass> CreateRectification(SomeClass  someInstance){

           await _dbContext.TenderRectifications.InsertOneAsync(someInstance);       … more