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); } }
public ActionResult Save(BrandInfoViewModel model) { var brandDto = new DtoBrand { Id = model.Id, Name = model.Name }; _brandService.SaveBrand(brandDto); return(RedirectToAction("Index")); }
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)); }
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); } }