Exemplo n.º 1
0
 private void Bt_changePriceAttraction_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (ModifyService.updatePriceAttraction(lb_priceAttraction.SelectedValue.ToString(), double.Parse(tb_prmodifyNewPrice.Text), cal_prmodifyWhenStart.SelectedDates.First(), cal_prmodifyWhenStart.SelectedDates.Last()))
         {
             MessageBox.Show("Zaaktualizowano cenę atrakcji");
             tb_prmodifyNewPrice.Text = "";
             tb_prmodifyOldPrice.Text = ModifyService.getPriceAttraction(lb_priceAttraction.SelectedValue.ToString()).ToString();
             gd_planned.ItemsSource   = ModifyService.getAttractionTimePeriods(lb_priceAttraction.SelectedValue.ToString());
         }
         else
         {
             MessageBox.Show("Błędna cena, data już zaplanowana lub z przeszłości");
         }
     }
     catch (InvalidOperationException)
     {
         MessageBox.Show("Nie wybrano zakresu obowiązywania");
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Nie wybrano zakresu obowiązywania lub atrakcji");
     }
     catch (FormatException)
     {
         MessageBox.Show("Nie wybrano nowej ceny");
     }
 }
Exemplo n.º 2
0
 private void Lb_priceAttraction_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     bt_changePrice.Visibility           = Visibility.Hidden;
     bt_changePriceAttraction.Visibility = Visibility.Visible;
     if (lb_priceAttraction.SelectedValue != null)
     {
         tb_prmodifyOldPrice.Text = ModifyService.getPriceAttraction(lb_priceAttraction.SelectedValue.ToString()).ToString();
     }
     gd_planned.ItemsSource = ModifyService.getAttractionTimePeriods(lb_priceAttraction.SelectedValue.ToString());
 }
Exemplo n.º 3
0
        private void Lb_priceAttraction_Loaded(object sender, RoutedEventArgs e)
        {
            List <string> list = new List <string>();

            foreach (var i in ModifyService.getAttractionName())
            {
                list.Add(i.name);
            }
            lb_priceAttraction.ItemsSource = list;
        }
Exemplo n.º 4
0
        private void Lb_priceList_Loaded(object sender, RoutedEventArgs e)
        {
            List <string> list = new List <string>();

            foreach (var i in ModifyService.getEntry())
            {
                list.Add(i.entry);
            }
            lb_priceList.ItemsSource = list;
        }
Exemplo n.º 5
0
        public void ThrowArgumentNullException_WhenAnItemToEditIsNotProvided()
        {
            // Arrange
            var dbSetWrapperMock         = new Mock <IEfDbSetWrapper <Photo> >();
            var dbContextSaveChangesMock = new Mock <IEfDbContextSaveChanges>();

            IModifyService <Photo> modifyService = new ModifyService <Photo>(dbSetWrapperMock.Object, dbContextSaveChangesMock.Object);

            // Act, Assert
            Assert.Throws <ArgumentNullException>(() => modifyService.Edit(null));
        }
Exemplo n.º 6
0
        public void InvokeUpdateMethodFromDbSetWrapper_WhenAnItemToEditIsProvided()
        {
            // Arrange
            var itemMock                 = new Mock <Tag>();
            var dbSetWrapperMock         = new Mock <IEfDbSetWrapper <Tag> >();
            var dbContextSaveChangesMock = new Mock <IEfDbContextSaveChanges>();

            IModifyService <Tag> modifyService = new ModifyService <Tag>(dbSetWrapperMock.Object, dbContextSaveChangesMock.Object);

            // Act
            modifyService.Edit(itemMock.Object);

            // Assert
            dbSetWrapperMock.Verify(x => x.Update(itemMock.Object), Times.Once);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ModifyService modifyService = new ModifyService();
            int           result        = modifyService.ModifyNotes(eventId, titleTextBox.Text, writeTextBox.Text, dateTimePicker.Text, importantComboBox.Text);

            if (result > 0)
            {
                MessageBox.Show("Modify Successfully");
                this.Refreash(this, null);
                this.Clear(this, null);
            }
            else
            {
                MessageBox.Show("Error Occur!");
            }
        }
        public async Task <ApiResponse <List <ServiceDTO> > > ModifyService(ModifyService modifyService)
        {
            ApiResponse <List <ServiceDTO> > result = new ApiResponse <List <ServiceDTO> >();

            try
            {
                var serviceToupdatePosition = await unitOfWork.ServicesManager.GetByIdAsync(modifyService.ServiceId); // gets service old position

                var allServices = await unitOfWork.ServicesManager.GetAsync(a => a.isDeleted == false);               // gets all services and order it

                allServices = allServices.OrderBy(a => a.position);
                List <Service> services = new List <Service>();
                if (serviceToupdatePosition != null)
                {
                    services = allServices.ToList();
                    // dragged down
                    if (modifyService.newPosition > modifyService.oldPosition)
                    {
                        services[modifyService.oldPosition].position = modifyService.newPosition;
                        // int serviceStopcondition = services.Count-(modifyService.newPosition - mod) ;


                        for (int i = modifyService.oldPosition + 1; i <= modifyService.newPosition; i++)
                        {
                            services[i].position = services[i].position - 1;
                        }
                    }
                    //draged up
                    else if (modifyService.newPosition < modifyService.oldPosition)
                    {
                        services[modifyService.oldPosition].position = modifyService.newPosition;


                        for (int i = modifyService.newPosition; i < modifyService.oldPosition; i++)
                        {
                            services[i].position = services[i].position + 1;
                        }
                    }

                    //  var lol = mapper.Map<Service>(services);
                    //  var Saves =   await unitOfWork.ServicesManager.UpdateAsync(lol);
                    var saved = await unitOfWork.SaveChangesAsync();

                    if (saved)
                    {
                        var GetLatest = await unitOfWork.ServicesManager.GetAsync();

                        var list = GetLatest.ToList();
                        if (list != null)
                        {
                            result.Succeeded = true;
                            result.Data      = mapper.Map <List <ServiceDTO> >(list);
                            return(result);
                        }
                        else
                        {
                            result.Succeeded = false;
                            result.Errors.Add("Can not Get list of services ");
                            return(result);
                        }
                    }
                    else
                    {
                        result.Succeeded = false;
                        result.Errors.Add("Can not save changes of Services ");
                        return(result);
                    }
                }
                else
                {
                    result.Succeeded = false;
                    result.Errors.Add("cannot get any service ");
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.Succeeded = false;
                result.Errors.Add(ex.Message);
                return(result);
            }
        }
        public async Task <ApiResponse <List <ServiceDTO> > > ModifyService(ModifyService modifyService)
        {
            ApiResponse <List <ServiceDTO> > result = new ApiResponse <List <ServiceDTO> >();

            try
            {
                var ServiceToDate = await unitOfWork.ServicesManager.GetByIdAsync(modifyService.ServiceId);

                if (ServiceToDate != null)
                {
                    var serviceToReplace = await unitOfWork.ServicesManager.GetAsync(a => a.position == modifyService.newPosition);

                    if (serviceToReplace.FirstOrDefault() != null)
                    {
                        ServiceToDate.position = modifyService.newPosition;
                        var serviceReplace = serviceToReplace.FirstOrDefault();
                        serviceReplace.position = modifyService.oldPosition;


                        var Saves = await unitOfWork.ServicesManager.UpdateAsync(ServiceToDate);

                        var saveChanges = await unitOfWork.ServicesManager.UpdateAsync(serviceReplace);

                        await unitOfWork.SaveChangesAsync();


                        if (saveChanges == true && Saves == true)
                        {
                            var GetLatest = await unitOfWork.ServicesManager.GetAsync();

                            var list = GetLatest.ToList();
                            if (list != null)
                            {
                                result.Succeeded = true;
                                result.Data      = mapper.Map <List <ServiceDTO> >(list);
                                return(result);
                            }
                            else
                            {
                                result.Succeeded = false;
                                result.Errors.Add("Can not Get list of services ");
                                return(result);
                            }
                        }
                        else

                        {
                            result.Succeeded = false;
                            result.Errors.Add("Can not save changes of Services ");
                            return(result);
                        }
                    }
                    else
                    {
                        result.Succeeded = false;
                        result.Errors.Add("Can not find the second Service ");
                        return(result);
                    }
                }
                else
                {
                    result.Succeeded = false;
                    result.Errors.Add("cannot get any service ");
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.Succeeded = false;
                result.Errors.Add(ex.Message);
                return(result);
            }
        }
Exemplo n.º 10
0
 public async Task <IActionResult> modifyservice(ModifyService modifyService)
 {
     return(await GetResponseHandler(async() => await service.ModifyService(modifyService)));
 }