Ejemplo n.º 1
0
        public void Update(InsertCategoryDTO entity, int id)
        {
            var cat = _unitOfWork.Category.Get(id);

            if (!String.IsNullOrEmpty(entity.Name))
            {
                cat.Name = entity.Name;
            }
            _unitOfWork.Save();
        }
Ejemplo n.º 2
0
        public int Insert(InsertCategoryDTO entity)
        {
            var cat = new Category
            {
                Name = entity.Name
            };

            _unitOfWork.Category.Add(cat);
            _unitOfWork.Save();
            return(cat.Id);
        }
Ejemplo n.º 3
0
 public IActionResult Put(int id, [FromBody] InsertCategoryDTO dto)
 {
     try
     {
         _categoryService.Update(dto, id);
         return(Ok("Succeffuly upated"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 4
0
 public IActionResult Post([FromBody] InsertCategoryDTO dto)
 {
     try
     {
         _categoryService.Insert(dto);
         return(Ok("Secceffuly creteed"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 5
0
 public ActionResult Edit(int id, IFormCollection collection)
 {
     try
     {
         var cat = new InsertCategoryDTO
         {
             Name = collection["Name"]
         };
         _categoryService.Update(cat, id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
0
        public async Task <ExecuteResult> InsertCategory(InsertCategoryDTO category)
        {
            List <StoredProcedure> storedProcedures = new List <StoredProcedure>();

            storedProcedures.Add(
                DbUtil.StoredProcedureBuilder.WithSPName("mscategory_insert")
                .AddParam(category.Name)
                .AddParam(category.AuditedUserId)
                .SP()
                );
            IEnumerable <ExecuteResultDTO> executeResults = await ExecSPWithTransaction <ExecuteResultDTO>(storedProcedures.ToArray());

            return(executeResults.Select(x => new ExecuteResult
            {
                InstanceId = x.InstanceId,
            }).FirstOrDefault());
        }
Ejemplo n.º 7
0
        public ActionResult Create(IFormCollection collection)
        {
            try
            {
                var category = new InsertCategoryDTO
                {
                    Name = collection["Name"]
                };
                _categoryService.Insert(category);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 8
0
 public void Delete(InsertCategoryDTO entity)
 {
     throw new NotImplementedException();
 }