Esempio n. 1
0
        public AksesuarContainerDto GetCard(int id, string company)
        {
            var container = new AksesuarContainerDto();
            var aksesuar  = _repository.QueryableNoTracking().FirstOrDefault(x => x.Id == id);

            if (aksesuar == null)
            {
                return(container);
            }
            if (aksesuar.Renkid.HasValue)
            {
                container.Renk = _repoRenk.QueryableNoTracking().FirstOrDefault(x => x.Id == aksesuar.Renkid);
            }
            if (aksesuar.PantoneId.HasValue)
            {
                container.PantoneRenk = _repoPantoneRenk.QueryableNoTracking().FirstOrDefault(x => x.Id == aksesuar.PantoneId);
            }
            if (!string.IsNullOrWhiteSpace(aksesuar.CompanyId))
            {
                container.Company = _repoCompany.QueryableNoTracking().FirstOrDefault(x => x.Id == aksesuar.CompanyId);
            }
            if (aksesuar.UlkeId.HasValue)
            {
                container.Ulke = _othersService.GetCountryById(aksesuar.UlkeId.Value);
            }
            container.RafyeriTurkiye = _termService.GetTermById(aksesuar.RafyeriTurkiyeId.Value);
            container.RafyeriTurkiye = _termService.GetTermById(aksesuar.RafyeriYunanistanId.Value);

            return(container);
        }
Esempio n. 2
0
        public void InsertOrUpdate(AksesuarContainerDto container)
        {
            try
            {
                _repository.UnitOfWorkAsync().BeginTransaction();
                var aksesuar = container.Aksesuar;
                if (aksesuar.Id > 0)
                {
                    this.Update(aksesuar);
                }
                else
                {
                    this.Insert(aksesuar);
                }
                _repository.UnitOfWorkAsync().SaveChanges();

                var kompozisyonlar = container.AksesuarKompozisyonlar;;

                if (kompozisyonlar != null && kompozisyonlar.Any())
                {
                    foreach (var kompozisyon in kompozisyonlar)
                    {
                        kompozisyon.AksesuarId = aksesuar.Id;
                        if (kompozisyon.Id > 0)
                        {
                            _repoKompozisyon.Update(kompozisyon);
                        }
                        else
                        {
                            _repoKompozisyon.Insert(kompozisyon);
                        }
                    }
                }

                _repository.UnitOfWorkAsync().SaveChanges();
                _repository.UnitOfWorkAsync().Commit();
            }
            catch (Exception ex)
            {
                _repository.UnitOfWorkAsync().Rollback();
                throw;
            }
        }
        public ActionResult Edit(AksesuarEditVm model)
        {
            var result = HandleException(() =>
            {
                var container = new AksesuarContainerDto();

                container.AksesuarKompozisyonlar = model.AksesuarKompozisyonlar;
                container.Aksesuar = model.Aksesuar;


                GetAksesuarService().InsertOrUpdate(container);
            });

            if (result)
            {
                return(RedirectToActionPermanent(actionName: "Index", controllerName: "ZetaCode"));
            }



            FillCollections(model);
            return(View(model));
        }