Exemplo n.º 1
0
        public async Task <BaseResponse> UpdateCategory(ModelCategoryView model)
        {
            BaseResponse response = new BaseResponse();

            using (var dbcxtransaction = await _context.Database.BeginTransactionAsync())
            {
                try
                {
                    var category = await _context.MasterVotingCategories.FindAsync(model.VotingCategoryId);

                    category.VotingCategoryName = model.VotingCategoryName;
                    category.ModifiedDate       = DateTime.Now;
                    category.ModifiedBy         = "Admin";

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

                    await _context.SaveChangesAsync();

                    dbcxtransaction.Commit();

                    response.Code    = (int)HttpStatusCode.OK;
                    response.Status  = HttpStatusCode.OK.ToString();
                    response.Message = "Update data success.";
                }
                catch (Exception ex)
                {
                    response.Message = ex.ToString();
                    response.Code    = (int)HttpStatusCode.InternalServerError;
                    response.Status  = HttpStatusCode.InternalServerError.ToString();

                    dbcxtransaction.Rollback();
                }
            }

            return(response);
        }
Exemplo n.º 2
0
        public async Task <BaseResponse> DeleteCategory([FromQuery] int id)
        {
            ModelCategoryView model = null;

            return(await _votingService.PostAsync(_configuration.GetValue <string>("VotingEndPoint:DeleteCategory") + "?id=" + id, model));
        }
Exemplo n.º 3
0
        public IActionResult Index()
        {
            ModelCategoryView model = new ModelCategoryView();

            return(View(model));
        }
Exemplo n.º 4
0
 public async Task <BaseResponse> UpdateCategory(ModelCategoryView model)
 {
     return(await _votingService.PostAsync(_configuration.GetValue <string>("VotingEndPoint:UpdateCategory"), model));
 }
Exemplo n.º 5
0
 public async Task <BaseResponse> UpdateCategory(ModelCategoryView model)
 {
     return(await _categoryRepository.UpdateCategory(model));
 }