public IActionResult DeleteVelemeny(string id)
        {
            Velemeny v = ReviewLogic.GetVelemeny(id);

            ReviewLogic.DeleteVelemeny(id);
            return(View(nameof(ListVelemeny), KnifeLogic.GetVelemenyek(v.Gyartasi_Cikkszam)));
        }
示例#2
0
        /// <summary>
        /// Modifies an element of the knifeStore list as intended.
        /// </summary>
        /// <param name="reviewToModify">The Reveiew entity which should be modified.</param>
        public void ModReview(Review reviewToModify, string token)
        {
            if (reviewToModify == null)
            {
                this.messengerService.Send("EDIT FAILED", "LogicResult");
                return;
            }

            Review clone = new Review();

            clone.CopyFrom(reviewToModify);
            if (this.editorService.EditReview(clone) == true)
            {
                try
                {
                    reviewToModify.CopyFrom(clone);
                    Velemeny kb = new Velemeny()
                    {
                        Velemeny_Id       = string.Empty,
                        VelemenySzovege   = clone.ReviewText == null ? string.Empty : clone.ReviewText,
                        Elegedettseg      = clone.Rating,
                        Szerzo            = clone.Author == null ? string.Empty : clone.Author,
                        Gyartasi_Cikkszam = clone.SerialNumber,
                    };


                    string api = hostSettings.Address() + $"Review" + $"/{reviewToModify.ReviewId}";
                    try
                    {
                        WebClient wc   = new WebClient();
                        var       json = JsonConvert.SerializeObject(kb);
                        wc.Headers[HttpRequestHeader.ContentType]   = "application/json";
                        wc.Headers[HttpRequestHeader.Authorization] = $"Bearer {token}";
                        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;
                }
                catch
                {
                    this.messengerService.Send("MÓDOSÍTÁS SIKERTELEN", "LogicResult");
                    return;
                }
            }
        }
 public IActionResult UpdateReview(string id, [FromBody] Velemeny newVelmeny)
 {
     try
     {
         reviewLogic.UpdateVelemeny(id, newVelmeny);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(StatusCode(400, $"Bad request error: {ex}"));
     }
 }
 public IActionResult AddReview([FromBody] Velemeny v)
 {
     try
     {
         v.Velemeny_Id = Guid.NewGuid().ToString();
         reviewLogic.AddVelemeny(v);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(StatusCode(500, $"Internal server error: {ex}"));
     }
 }
示例#5
0
 /// <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 AddReview(IList <Review> list, string selectedKnifeId, string token)
 {
     try
     {
         Review newReview = new Review();
         if ((selectedKnifeId != null && selectedKnifeId != string.Empty) && this.editorService.EditReview(newReview) == true)
         {
             Velemeny kb = new Velemeny()
             {
                 Velemeny_Id       = string.Empty,
                 VelemenySzovege   = newReview.ReviewText == null ? string.Empty : newReview.ReviewText,
                 Elegedettseg      = newReview.Rating,
                 Szerzo            = newReview.Author == null ? string.Empty : newReview.Author,
                 Gyartasi_Cikkszam = selectedKnifeId,
             };
             string    api  = hostSettings.Address() + $"Review";
             WebClient wc   = new WebClient();
             var       json = JsonConvert.SerializeObject(kb);
             wc.Headers[HttpRequestHeader.ContentType]   = "application/json";
             wc.Headers[HttpRequestHeader.Authorization] = $"Bearer {token}";
             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;
     }
 }
 public IActionResult EditVelemeny(Velemeny v)
 {
     ReviewLogic.UpdateVelemeny(v.Velemeny_Id, v);
     return(RedirectToAction(nameof(ListVelemeny), new { id = v.Gyartasi_Cikkszam }));
 }
        public IActionResult EditVelemeny(string id)
        {
            Velemeny v = ReviewLogic.GetVelemeny(id);

            return(View(v));
        }
 public IActionResult AddVelemeny(Velemeny velemeny)
 {
     velemeny.Velemeny_Id = Guid.NewGuid().ToString();
     ReviewLogic.AddVelemeny(velemeny);
     return(View(nameof(ListVelemeny), KnifeLogic.GetVelemenyek(velemeny.Gyartasi_Cikkszam)));
 }
示例#9
0
 public void UpdateVelemeny(string o_vid, Velemeny n_review)
 {
     VelemenyRepo.Update(o_vid, n_review);
 }
示例#10
0
 public void AddVelemeny(Velemeny velemeny)
 {
     this.VelemenyRepo.Add(velemeny);
 }