Exemplo n.º 1
0
        public async Task <ActionResult <TblCategoryMaster> > PostTblCategoryMaster(TblCategoryMaster tblCategoryMaster)
        {
            _context.TblCategoryMaster.Add(tblCategoryMaster);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTblCategoryMaster", new { id = tblCategoryMaster.Id }, tblCategoryMaster));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutTblCategoryMaster(long id, TblCategoryMaster tblCategoryMaster)
        {
            if (id != tblCategoryMaster.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tblCategoryMaster).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblCategoryMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <ActionResult <ApiResponse> > GetCategoryById(TblCategoryMaster tblCategoryObj)
        {
            var tblCategoryMaster = await _context.TblCategoryMaster.FindAsync(tblCategoryObj.Id);

            var ApiResponse = await response.ApiResult("OK", tblCategoryMaster, " Add Record");

            return(ApiResponse);
        }
Exemplo n.º 4
0
        public async Task <ActionResult <ApiResponse> > AllCategory(TblCategoryMaster tblobj)
        {
            var items = await _context.TblCategoryMaster.Where(i => i.Type == tblobj.Type).ToListAsync();

            var ApiResponse = await response.ApiResult("OK", items, "Record Found");

            return(ApiResponse);
        }
Exemplo n.º 5
0
        public async Task <ActionResult <ApiResponse> > AddCategory(TblCategoryMaster tblCategoryMaster)
        {
            _context.TblCategoryMaster.Add(tblCategoryMaster);
            await _context.SaveChangesAsync();

            var ApiResponse = await response.ApiResult("OK", tblCategoryMaster.Id, " Add Record");

            return(ApiResponse);
        }
Exemplo n.º 6
0
        public async Task <ActionResult <ApiResponse> > AllModel(TblCategoryMaster tblobj)
        {
            var listmodel = await _context.TblCategoryMaster.ToListAsync();

            var listmodelInner = await _context.TblCategoryMaster.ToListAsync();

            var items = (from lm in listmodel
                         join lmi in listmodelInner on lm.Id equals lmi.ParentId
                         select new { id = lm.Id, makerName = lm.CategoryType, parentId = lm.ParentId, modelName = lmi.CategoryType,
                                      type = lmi.Type, modelId = lmi.Id })
                        .Where(i => i.type == tblobj.Type).ToList();

            var ApiResponse = await response.ApiResult("OK", items, "Record Found");

            return(ApiResponse);
        }
Exemplo n.º 7
0
        public async Task <ApiResponse> UpdateCategory(TblCategoryMaster tblCategoryMaster)
        {
            _context.Entry(tblCategoryMaster).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                var ApiResponse = await response.ApiResult("OK", tblCategoryMaster.Id, " Update Record");

                return(ApiResponse);
            }
            catch (DbUpdateConcurrencyException EX)
            {
                var ApiResponsError = await response.ApiResult("FAILED", EX, "Errro Updating");

                return(ApiResponsError);
            }
        }