コード例 #1
0
        public IActionResult Add(Plaka plaka)
        {
            var result = _plakaService.Add(plaka);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
コード例 #2
0
        public IResult Add(GarantiDetayDto garantiDetayDto)
        {
            Plaka tempPlaka = new Plaka
            {
                PlakaNo = garantiDetayDto.PlakaNo.ToUpper()
            };

            var resultPlaka = _plakaService.Add(tempPlaka);

            if (!resultPlaka.Success)
            {
                tempPlaka = _plakaService.GetByPlakaNo(tempPlaka.PlakaNo).Data;
            }

            GarantiDetay garantiDetay = new GarantiDetay
            {
                SeriNo      = garantiDetayDto.SeriNo,
                Fiyat       = garantiDetayDto.Fiyat,
                AkuTipiID   = _akuTipiService.GetByName(garantiDetayDto.AkuTipi).Data.AkuTipiID,
                AmperID     = _amperService.GetByName(garantiDetayDto.Amper).Data.AmperID,
                MarkaID     = _markaService.GetByName(garantiDetayDto.Marka).Data.MarkaID,
                PlakaID     = tempPlaka.PlakaID,
                Description = garantiDetayDto.Description,
                IsActive    = true,
                CreatedDate = DateTime.Now,
                UpdatedDate = DateTime.Now
            };

            _garantiDetayDal.Add(garantiDetay);

            if (garantiDetayDto.AkuOzellik != null)
            {
                foreach (var ozellik in garantiDetayDto.AkuOzellik)
                {
                    GarantiDetayToAkuOzellik tempGarantiDetayToAkuOzellik = new GarantiDetayToAkuOzellik
                    {
                        GarantiDetayID = garantiDetay.GarantiDetayID,
                        AkuOzellikID   = ozellik.AkuOzellikID,
                        CreatedDate    = DateTime.Now,
                        UpdatedDate    = DateTime.Now
                    };
                    _garantiDetayToAkuOzellikService.Add(tempGarantiDetayToAkuOzellik);
                }
            }

            return(new SuccessResult(Messages.GarantiDetayAdded));
        }