Archives

Archives / 2016 / March
  • How to unit test web api controller with Uploader

    Hello everybody,

    today I want to share piece of code of how to unit test web API2 controller. 

    So, recently I had the following task, make web api controller, which accepts posted files, and does something with them. But because at that project I was in role of back end developer ( not full-stack ), it wasn't possible for me to write client side javascript for posting files. What is common way to behave for server side developers? If you proposed to write unit test which will imitate creating and uploading file you are 100% correct. That was my decision as well. 

    I don't know how about you, but if it is needed to work with uploaded files, I used to work with HttpContext.Current.Request. … more

  • New web services features in Acumatica

    Hello everybody,

    today I want to share with you one way of importing data from Acumatica. 

    After many versions of binding to strings Acumatica made really big change in their web service decisions. They made their services more compile time oriented. 

    Adding new web service reference should be done only in the following way:

    1. In  the menu select Project -> Add Service reference

    2. In the Pop up type something like "https://localhost/WebServiceAPITest/entity/Default/5.30.001?wsdl" without quotes.   

    3. Click Go

    4. Here you can feel some freedom, and give namespace which you prefer for your web services.

    5. Click Ok.

     

    Here I want to post way how to get all Stock items with … more

  • 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

  • CRUD with MongoDB version 2

    Hello everybody,

    today I want to describe CRUD options in MongoDB version 2.

    So, let's start with Reading. 

    In MongoDB reading can be considered as following options:

    Finding all documnets

    Filtering

    Sorting

    Definitions and builders.

    Creating documents in MongoDB is simple. You can do it just with Insert ( letter C ). 

    And here you have plenty of options:

    Replace

    Update

    Upsert

    I'll also mention deleting, or letter D.

    And also I want to describe how to use projections as way to limit what you take from MongoDB

    So, let's start with synchronous finding of some information in MongoDB. 

    Suppose I have following classes declarations:

    public abstract class MongoEntityBase

      … more