示例#1
0
 public IActionResult UpdateKnifeStore(string id, [FromBody] Kes_Bolt newKnifeStore)
 {
     try
     {
         knifeStoreLogic.UpdateKes_Bolt(id, newKnifeStore);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(StatusCode(400, $"Bad request error: {ex}"));
     }
 }
示例#2
0
 public IActionResult AddKnifeStore([FromBody] Kes_Bolt k)
 {
     try
     {
         k.Raktar_Id = Guid.NewGuid().ToString();
         knifeStoreLogic.AddKesBolt(k);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(StatusCode(500, $"Internal server error: {ex}"));
     }
 }
        /// <summary>
        /// Modifies an element of the knifeStore list as intended.
        /// </summary>
        /// <param name="knifeStoreToModify">The KnifeStore entity which should be modified.</param>
        public void ModKnifeStore(KnifeStore knifeStoreToModify, string token)
        {
            if (knifeStoreToModify == null)
            {
                this.messengerService.Send("MÓDOSÍTÁS SIKERTELEN", "LogicResult");
                return;
            }

            KnifeStore clone = new KnifeStore();

            clone.CopyFrom(knifeStoreToModify);
            if (this.editorService.EditKnifeStore(clone) == true)
            {
                knifeStoreToModify.CopyFrom(clone);
                Kes_Bolt kb = new Kes_Bolt()
                {
                    Raktar_Id = clone.StorageId,
                    Bolt_Nev  = clone.Name,
                    Cim       = clone.Address,
                    Weboldal  = clone.Website,
                };


                string api = hostSettings.Address() + $"KnifeStore" + $"/{knifeStoreToModify.StorageId}";
                try
                {
                    WebClient wc   = new WebClient();
                    var       json = JsonConvert.SerializeObject(kb);
                    wc.Headers[HttpRequestHeader.Authorization] = $"Bearer {token}";
                    wc.Headers[HttpRequestHeader.ContentType]   = "application/json";
                    wc.UploadString(api, "PUT", json);
                }
                catch (Exception ex)
                {
                    if (ex.Message.ToString().Contains("403"))
                    {
                        this.messengerService.Send("MÓDOSÍTÁS SIKERTELEN\nNINCS ENGEDÉLYE EHHEZ", "LogicResult");
                        return;
                    }
                    this.messengerService.Send("MÓDOSÍTÁS SIKERTELEN", "LogicResult");
                    return;
                }
                //this.knifeStoreLogic.UpdateKes_Bolt(knifeStoreToModify.StorageId, kb);
                this.messengerService.Send("MÓDOSÍTÁS SIKERES", "LogicResult");
                return;
            }

            this.messengerService.Send("MÓDOSÍTÁS MEGSZAKÍTVA", "LogicResult");
        }
示例#4
0
        public void GetKesBolt()
        {
            Mock <IRepository <Kes_Bolt> > MockoltKesBoltRepo = new Mock <IRepository <Kes_Bolt> >(MockBehavior.Loose);
            Kes_Bolt TesztKesBolt = new Kes_Bolt()
            {
                Raktar_Id = Guid.NewGuid().ToString(),
                Bolt_Nev  = "Extrametál Kés (üzlethálózat)",
                Cim       = "Extrametál,Magyarország",
                Weboldal  = "https://extrametal.hu/"
            };
            Kes_Bolt ElvartKesBolt = TesztKesBolt;

            MockoltKesBoltRepo.Setup(x => x.Read(TesztKesBolt.Raktar_Id)).Returns(TesztKesBolt);
            KesBoltLogic kesBoltLogic = new KesBoltLogic(MockoltKesBoltRepo.Object);
            var          Kimenet      = kesBoltLogic.GetKes_Bolt(TesztKesBolt.Raktar_Id);

            Assert.That(Kimenet, Is.EqualTo(ElvartKesBolt));
        }
        /// <summary>
        /// Adds a new KnifeStore to it's list and calls the database operation to syncronhize them.
        /// </summary>
        /// <param name="list">The entity list where the entity should be added.</param>
        public void AddKnifeStore(IList <KnifeStore> list, string token)
        {
            try
            {
                KnifeStore newKnifeStore = new KnifeStore();
                if (this.editorService.EditKnifeStore(newKnifeStore) == true)
                {
                    Kes_Bolt kb = new Kes_Bolt()
                    {
                        Raktar_Id = string.Empty,
                        Bolt_Nev  = newKnifeStore.Name,
                        Cim       = newKnifeStore.Address,
                        Weboldal  = newKnifeStore.Website,
                    };
                    string    api = hostSettings.Address() + $"KnifeStore";
                    WebClient wc  = new WebClient();
                    wc.Headers[HttpRequestHeader.Authorization] = $"Bearer {token}";
                    var json = JsonConvert.SerializeObject(kb);
                    wc.Headers[HttpRequestHeader.ContentType] = "application/json";
                    wc.UploadString(api, "POST", json);
                    this.messengerService.Send("HOZZÁADÁS SIKERES", "LogicResult");
                    return;
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.ToString().Contains("403"))
                {
                    this.messengerService.Send("HOZZÁADÁS SIKERTELEN\nNINCS ENGEDÉLYE EHHEZ", "LogicResult");
                    return;
                }
                this.messengerService.Send("HOZZÁADÁS SIKERTELEN", "LogicResult");
                return;
            }

            this.messengerService.Send("HOZZÁADÁS MEGSZAKÍTVA", "LogicResult");
        }
 public IActionResult EditKesBolt(Kes_Bolt kb)
 {
     KnifeStoreLogic.UpdateKes_Bolt(kb.Raktar_Id, kb);
     return(RedirectToAction(nameof(ListKesBolt)));
 }
        public IActionResult EditKesBolt(string id)
        {
            Kes_Bolt kb = KnifeStoreLogic.GetKes_Bolt(id);

            return(View(kb));
        }
 public IActionResult AddKesBolt(Kes_Bolt kesbolt)
 {
     kesbolt.Raktar_Id = Guid.NewGuid().ToString();
     KnifeStoreLogic.AddKesBolt(kesbolt);
     return(RedirectToAction(nameof(ListKesBolt)));
 }
 public void UpdateKes_Bolt(string o_kbid, Kes_Bolt n_kesbolt)
 {
     KesBoltRepo.Update(o_kbid, n_kesbolt);
 }
示例#10
0
 public void AddKesBolt(Kes_Bolt kesBolt)
 {
     this.KesBoltRepo.Add(kesBolt);
 }