Example #1
0
        public async Task AddAreaMaster(AreaMaster prodData)
        {
            var maxId = await WithConnection(async c =>
            {
                return await c.QueryAsync<int>("SELECT max(AreaIndex) FROM AreaMaster");
            });

            //Setting Primary Key
            if (maxId.SingleOrDefault() == 0)
            {
                prodData.AreaIndex = 1;
            }
            else
            {
                prodData.AreaIndex = maxId.SingleOrDefault() + 1;
            }

            //Filling Other Records like User Id, Creation & Update Date
            prodData.CreateUserIndex = 1; //Later Logged in User
            prodData.UpdateUserIndex = 1; //Later Logged in User
            prodData.CreateDateTime = DateTime.Now;
            prodData.UpdateDateTime = DateTime.Now;

            await WithConnection(async c =>
            {
                return await c.QueryAsync<int>(SQLConstants.InsertAreaMaster, prodData);
            });
        }
 public async Task<IHttpActionResult> Create(AreaMaster prodData)
 {
     if (prodData != null)
     {
         await AreaMasterDA.AddAreaMaster(prodData);
         return Ok();
     }
     return BadRequest("Request cannot be NULL");
 }