示例#1
0
        public bool Exec(LocalNetwork network, long id, ref DtoBrand dto)
        {
            try
            {
                using (var db = GetConnection(network))
                {
                    var u = repository.GetBrand(db, id);

                    dto = new DtoBrand
                    {
                        id   = u.id,
                        name = u.stName
                    };
                }

                return(true);
            }
            catch (Exception ex)
            {
                Error = new DtoServiceError
                {
                    message   = getLanguage("0", 0),
                    debugInfo = ex.ToString()
                };

                return(false);
            }
        }
示例#2
0
        public ActionResult Save(BrandInfoViewModel model)
        {
            var brandDto = new DtoBrand {
                Id = model.Id, Name = model.Name
            };

            _brandService.SaveBrand(brandDto);

            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult <DtoBrand> brand([FromQuery] string id)
        {
            var repo = new DapperAdminRepository();
            var srv  = new SrvBrandGetV1(repo, cache);
            var dto  = new DtoBrand();

            if (!srv.Exec(network, Convert.ToInt32(id), ref dto))
            {
                return(BadRequest(srv.Error));
            }

            return(Ok(dto));
        }
示例#4
0
        public void SaveBrand(DtoBrand brandDto)
        {
            var brand = new Brand
            {
                Id   = brandDto.Id,
                Name = brandDto.Name
            };

            if (brand.Id == 0)
            {
                _brandRepository.Add(brand);
            }
            else
            {
                _brandRepository.Update(brand);
            }
        }