예제 #1
0
        //        private readonly IRepositoryAsync<ZetaCodeKumasMakine> _repoKumasMakine;
        //        private readonly IRepositoryAsync<ZetaCodeYikamaTalimati> _repoYikamaTalimati;
        //        private readonly IRepositoryAsync<ZetaCodeNormalIplik> _repoNormalIplik;
        //        private readonly IRepositoryAsync<ZetaCodeFanteziIplik> _repoFanteziIplik;

        public KumasOrmeDokumaContainerDto GetCard(int id, string companyId)
        {
            var container = new KumasOrmeDokumaContainerDto();
            var entity    = _repository.QueryableNoTracking().FirstOrDefault(x => x.Id == id);

            if (entity == null)
            {
                return(container);
            }

            if (entity.KumasMakineId.HasValue)
            {
                container.KumasMakine = _repoKumasMakine.QueryableNoTracking().FirstOrDefault(x => x.Id == entity.KumasMakineId);
            }

            if (entity.YikamaTalimatiId.HasValue)
            {
                container.YikamaTalimati = _repoYikamaTalimati.QueryableNoTracking().FirstOrDefault(x => x.Id == entity.YikamaTalimatiId);
            }

            if (entity.YikamaTalimatiId.HasValue)
            {
                container.YikamaTalimati = _repoYikamaTalimati.QueryableNoTracking().FirstOrDefault(x => x.Id == entity.YikamaTalimatiId);
            }

            var normalIpliklerQuery  = _repoNormalIplikler.QueryableNoTracking();
            var fanteziIpliklerQuery = _repoFanteziIplikler.QueryableNoTracking();
            var normalIplikQuery     = _repoNormalIplik.QueryableNoTracking();
            var fanteziIplikQuery    = _repoFanteziIplik.QueryableNoTracking();
            var kumasQuery           = _repository.QueryableNoTracking();

            var normalIplikler = (from k in kumasQuery
                                  join n in normalIpliklerQuery on k.Id equals n.NormalKumasId
                                  join i in normalIplikQuery on n.NormalIplikId equals i.Id
                                  select i).ToList();


            var fanteziIplikler = (from k in kumasQuery
                                   join f in fanteziIpliklerQuery on k.Id equals f.NormalKumasId
                                   join i in fanteziIplikQuery on f.FanzteziIplikId equals i.Id
                                   select i).ToList();

            if (normalIplikler.Any())
            {
                container.NormalIplikler = normalIplikler;
            }

            if (fanteziIplikler.Any())
            {
                container.FanteziIplikler = fanteziIplikler;
            }

            return(container);
        }
예제 #2
0
        public ActionResult Card(int id, string companyId)
        {
            KumasOrmeDokumaContainerDto container = GetKumasOrmeDokumaService().GetCard(id, companyId);


            var view = new ZetaCodeKumasOrmeDokumaCardVm();

            view.Container = container;

            return(View(model: view));
        }
예제 #3
0
        public ActionResult Edit(ZetaCodeKumasOrmeDokumaEditVm model)
        {
            var result = HandleException(() =>
            {
                var container = new KumasOrmeDokumaContainerDto();
                if (model.Iplikler != null && model.Iplikler.Any())
                {
                    for (int i = 0; i < model.Iplikler.Count; i++)
                    {
                        if (string.IsNullOrWhiteSpace(model.Iplikler[i].Id))
                        {
                            continue;
                        }

                        var arr       = model.Iplikler[i].Id.Split('|');
                        var id        = arr[0].Trim();
                        var iplikTipi = arr[1].Trim();
                        //if (string.Equals(iplikTipi, "Normaliplik", StringComparison.InvariantCultureIgnoreCase))
                        //{
                        //    container.NormalIplikler.Add(new Service.DataTransferObjects.ZetaCodeNormalIplikDto()
                        //    {
                        //        Id = id.AsInt()
                        //    });
                        //}
                        //else if (string.Equals(iplikTipi, "Fanzteziiplik", StringComparison.InvariantCultureIgnoreCase))
                        //{
                        //    container.FanteziIplikler.Add(new Service.DataTransferObjects.ZetaCodeFanteziIplikDto()
                        //    {
                        //        Id = id.AsInt()
                        //    });
                        //}
                    }
                }
                container.KumasOrmeDokuma = model.KumasOrmeDokuma;
                container.KumasMakine     = model.KumasMakine;
                container.YikamaTalimati  = model.YikamaTalimati;
                GetKumasOrmeDokumaService().InsertOrUpdate(container);
            });

            if (result)
            {
                return(RedirectToActionPermanent(actionName: "Index", controllerName: "ZetaCode"));
            }
            FillCollections(model);
            return(View(model));
        }
예제 #4
0
        public void InsertOrUpdate(KumasOrmeDokumaContainerDto container)
        {
            try
            {
                _repository.UnitOfWorkAsync().BeginTransaction();

                var kumasOrmeDokuma = container.KumasOrmeDokuma;
                if (kumasOrmeDokuma.Id > 0)
                {
                    this.Update(kumasOrmeDokuma);
                }
                else
                {
                    this.Insert(kumasOrmeDokuma);
                }

                _repository.UnitOfWorkAsync().SaveChanges();

                var yikamaTalimati = container.YikamaTalimati;



                if (yikamaTalimati.Id > 0)
                {
                    _repoYikamaTalimati.Update(yikamaTalimati);
                }
                else
                {
                    _repoYikamaTalimati.Insert(yikamaTalimati);
                }

                var kumasMakine = container.KumasMakine;
                if (kumasMakine.Id > 0)
                {
                    _repoKumasMakine.Update(kumasMakine);
                }
                else
                {
                    _repoKumasMakine.Insert(kumasMakine);
                }

                _repository.UnitOfWorkAsync().SaveChanges();

                kumasOrmeDokuma.YikamaTalimatiId = yikamaTalimati.Id;
                kumasOrmeDokuma.KumasMakineId    = kumasMakine.Id;
                this.Update(kumasOrmeDokuma);
                _repository.UnitOfWorkAsync().SaveChanges();
                if (container.NormalIplikler != null && container.NormalIplikler.Any())
                {
                    var normalIplikler = container.NormalIplikler;
                    for (int i = 0; i < normalIplikler.Count; i++)
                    {
                        //if (normalIplikler[i].NormalKumasId > 0)
                        //{

                        //}
                        //else
                        //{

                        //}
                    }
                }

                if (container.FanteziIplikler != null && container.FanteziIplikler.Any())
                {
                    var fanteziIplikler = container.FanteziIplikler;
                    for (int i = 0; i < fanteziIplikler.Count; i++)
                    {
                        //if (fanteziIplikler[i].NormalKumasId > 0)
                        //{

                        //}
                        //else
                        //{

                        //}
                    }
                }

                this.Update(kumasOrmeDokuma);
                _repository.UnitOfWorkAsync().SaveChanges();
                _repository.UnitOfWorkAsync().Commit();
            }
            catch (Exception ex)
            {
                _repository.UnitOfWorkAsync().Rollback();
                throw;
            }
        }
예제 #5
0
 public ZetaCodeKumasOrmeDokumaCardVm()
 {
     Container = new KumasOrmeDokumaContainerDto();
 }