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

            //Setting Primary Key
            if (maxId.SingleOrDefault() == 0)
            {
                prodData.SE_ID = 1;
            }
            else
            {
                prodData.SE_ID = 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.InsertSEMaster, prodData));
            });
        }
        public async Task <IHttpActionResult> Create(SeMaster prodData)
        {
            if (prodData != null)
            {
                await SEMasterDA.AddSEMaster(prodData);

                return(Ok());
            }
            return(BadRequest("Request cannot be NULL"));
        }