Ejemplo n.º 1
0
        public async Task <BayiResponse> UpdateBayiAsync(Bayi bayi, int bayiId)
        {
            try
            {
                Bayi bayiguncel = await bayiRepository.FindByIdAsync(bayiId);

                if (bayiguncel == null)
                {
                    return(new BayiResponse("Bayi bulamadı."));
                }
                else
                {
                    bayiguncel.BayiAd    = bayi.BayiAd;
                    bayiguncel.BayiMail  = bayi.BayiMail;
                    bayiguncel.BayiAdres = bayi.BayiAdres;

                    bayiRepository.UpdateBayiAsync(bayiguncel);
                    unitOfWork.CompleteAsync();

                    return(new BayiResponse(bayiguncel));
                }
            }
            catch (Exception ex)
            {
                return(new BayiResponse($"Bayi güncellenirken bir hata oluştu.{ex.Message}"));
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Bayi kargo = DatabaseContext.Bayis.Find(id);

            DatabaseContext.Bayis.Remove(kargo);
            DatabaseContext.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(int id, Bayi model)
 {
     if (ModelState.IsValid)
     {
         DatabaseContext.Entry(model).State = EntityState.Modified;
         DatabaseContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Bayi kargo = DatabaseContext.Bayis.Find(id);

            if (kargo == null)
            {
                return(HttpNotFound());
            }
            return(View(kargo));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Bayi bayi = DatabaseContext.Bayis.Find(id);

            if (bayi == null)
            {
                return(HttpNotFound());
            }
            return(View(bayi));
        }
        public ActionResult Create(Bayi model)
        {
            // TODO: Add insert logic here
            if (ModelState.IsValid)
            {
                DatabaseContext.Bayis.Add(model);
                DatabaseContext.SaveChanges();
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }



            return(View(model));
        }
        public ActionResult YeniOlustur(Bayi model)
        {
            // TODO: Add insert logic here
            if (ModelState.IsValid)
            {
                DatabaseContext.Bayis.Add(model);
                DatabaseContext.SaveChanges();
                return(RedirectToAction("Index"));
            }



            return(View(model));
        }
Ejemplo n.º 8
0
        public async Task <BayiResponse> AddBayiAsync(Bayi bayi)
        {
            try
            {
                await bayiRepository.AddBayiAsync(bayi);

                unitOfWork.CompleteAsync();

                return(new BayiResponse(bayi));
            }
            catch (Exception ex)
            {
                return(new BayiResponse($"Bayi eklenirken bir hata oluştu : {ex.Message}"));
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> AddBayi(BayiResource bayiResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }

            Bayi bayi = mapper.Map <BayiResource, Bayi>(bayiResource);

            BayiResponse bayiResponse = await bayiService.AddBayiAsync(bayi);

            if (bayiResponse.Success)
            {
                return(Ok(bayiResponse.Bayi));
            }
            else
            {
                return(BadRequest(bayiResponse.Message));
            }
        }
Ejemplo n.º 10
0
        public async Task <BayiResponse> RemoveBayiAsync(int bayiId)
        {
            try
            {
                Bayi bayi = await bayiRepository.FindByIdAsync(bayiId);

                if (bayi == null)
                {
                    return(new BayiResponse("Bayi bulunmadı"));
                }
                else
                {
                    await bayiRepository.RemoveBayiAsync(bayiId);

                    unitOfWork.CompleteAsync();
                    return(new BayiResponse(bayi));
                }
            }
            catch (Exception ex)
            {
                return(new BayiResponse($"Bayi silinirken hata oluştu : {ex.Message}"));
            }
        }
Ejemplo n.º 11
0
 public void UpdateBayiAsync(Bayi bayi)
 {
     _context.Bayi.Update(bayi);
 }
Ejemplo n.º 12
0
 public async Task AddBayiAsync(Bayi bayi)
 {
     await _context.Bayi.AddAsync(bayi);
 }
Ejemplo n.º 13
0
 //başarılı olurşa
 public BayiResponse(Bayi bayi) : this(true, string.Empty, bayi)
 {
 }
Ejemplo n.º 14
0
 private BayiResponse(bool success, string message, Bayi Bayi) : base(success, message)
 {
     this.Bayi = Bayi;
 }