示例#1
0
        public async Task <IActionResult> Create(Category c)
        {
            var createCategory = await _category.AddAsync(c);

            if (createCategory)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
示例#2
0
        public async Task <IActionResult> AddCategory([FromBody] Category category)
        {
            var createCategory = await _category.AddAsync(category);

            if (createCategory)
            {
                return(Ok("Category Created"));
            }
            else
            {
                return(BadRequest(new { message = "Unable to create Category details" }));
            }
        }
        public async Task <IActionResult> Create(Category category)
        {
            category.CreatedBy = _userManager.GetUserName(User);

            var createCategory = await _category.AddAsync(category);

            if (createCategory)
            {
                Alert("Category created successfully!", NotificationType.success);
                return(RedirectToAction("Index"));
            }
            Alert("Category not created!", NotificationType.error);
            return(View());
        }
        public async Task <IActionResult> Create(Category c)
        {
            var createCategory = await _category.AddAsync(c);

            if (createCategory)
            {
                Alert("Category Created successfully.", NotificationType.success);
                return(RedirectToAction("Index"));
            }
            else
            {
                Alert("Category not Created!", NotificationType.error);
            }
            return(View());
        }
示例#5
0
        public async Task <IActionResult> Create(Category category)
        {
            category.CreatedBy   = _userManager.GetUserName(User);
            category.DateCreated = DateTime.Now;
            var createCategory = await _category.AddAsync(category);

            if (createCategory)
            {
                Alert("Category created successfully.", NotificationType.success);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                Alert("Category not created.", NotificationType.success);
            }
            return(View());
        }
        public async Task <Response <CategoryModel> > Post([FromBody] CategoryModel model)
        {
            Response <CategoryModel> categoryResponseModel = new Response <CategoryModel>();

            try
            {
                Category entity = _mapper.Map <Category>(model);
                entity = await(model.Id != Guid.Empty ? _category.UpdateAsync(entity) : _category.AddAsync(entity));
                categoryResponseModel.Value     = _mapper.Map <CategoryModel>(entity);
                categoryResponseModel.IsSuccess = true;
            }
            catch (Exception e)
            {
                categoryResponseModel.Exception = e;
                categoryResponseModel.IsSuccess = false;
            }

            return(categoryResponseModel);
        }