public ActionResult Create(Service service, int?DaysNumber) { if (ModelState.IsValid) { service.PostedDate = DateTime.Now; service.UserId = User.Identity.GetUserId(); service.IPAddress = Request.UserHostAddress; if (DaysNumber.HasValue) { service.ExpirationDate = service.PostedDate.AddDays(DaysNumber.Value); } else { service.ExpirationDate = service.PostedDate.AddDays(daysNumber); } _serviceRepo.Add(service); _serviceRepo.SaveChanges(); TempData["Message"] = "Usługa została dodana"; return(RedirectToAction("Details", new { id = service.ServiceId })); } TempData["Error"] = "Uzupełnij poprawnie formularz"; ViewBag.CategoryId = new SelectList(_categoryRepo.GetAllCategories(), "CategoryId", "Name"); return(View(service)); }
public void ServiceRepositoryAddRemove() { IServiceRepository serviceRepository = new ServiceRepository(); serviceRepository.Add(JabberService); Assert.AreEqual(true, serviceRepository.HasAtempt(JabberService)); var service = serviceRepository.GetService(JabberService); Assert.AreEqual(0, service.Attempt); Assert.AreEqual(JabberService, service.ServiceName); serviceRepository.Remove(JabberService); try { serviceRepository.GetService(JabberService); } catch (InvalidOperationException) { // Expected exception return; } catch (Exception ex) { Assert.Fail(ex.ToString()); } Assert.Fail("Error! Never get this command."); }
public JsonResult AddService() { try { ServiceRepository serviceRepo = new ServiceRepository(); Service service = new Service(); service.IsActive = true; service.Name = Request.Form["Name"]; service.Price = decimal.Parse(Request.Form["Cost"]); serviceRepo.Add(service); return(Json(new { error = false, Name = service.Name, Id = service.Id })); } catch { return(Json(new { error = true })); } }
public void CheckJabber() { CheckServiceApiController controller = null; try { controller = new CheckServiceApiController(); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); IServiceRepository serviceRepository = new ServiceRepository(); serviceRepository.Add(JabberService); controller.ServiceRepository = serviceRepository; HealthCheckRunner.ServiceNames = new List <string> { JabberService }; HttpResponseMessage response = controller.GetState(); dynamic status; response.TryGetContentValue(out status); Assert.IsTrue(response.IsSuccessStatusCode); Assert.AreEqual(1, status.code); } finally { if (controller != null) { controller.Dispose(); } } }
public async Task AddTeam(NewTeamDTO dto) { var team = new DAL.App.DTO.Team(); team.Description = dto.Description; team.Name = dto.Name; ServiceRepository.Add(team); await ServiceUnitOfWork.SaveChangesAsync(); }
public async Task AddPosition(string position, Guid userId) { var playerPostion = new DAL.App.DTO.PlayerPosition() { AppUserId = userId, PersonPosition = position }; ServiceRepository.Add(playerPostion); await ServiceUnitOfWork.SaveChangesAsync(); }
public void ServiceRepositorySetStates() { var serviceRepository = new ServiceRepository(); serviceRepository.Add(JabberService); serviceRepository.SetStates(JabberService, HealthCheckResource.StatusServiceStoped, HealthCheckResource.ServiceStop); var service = serviceRepository.GetService(JabberService); Assert.AreEqual(0, service.Attempt); Assert.AreEqual(JabberService, service.ServiceName); Assert.AreEqual(HealthCheckResource.ServiceStop, service.Message); }
public async Task <BaseLiftSet> AddBaseLiftSetAsync(BaseLiftSet baseSet) { var entityToAdd = Mapper.MapBaseLiftSetToDALEntity(baseSet); var routineId = await ServiceRepository.GetRoutineIdForExerciseSetAsync(entityToAdd.ExerciseInTrainingDayId); entityToAdd.WorkoutRoutineId = routineId; entityToAdd.SetNumber = await GetSetNumber(baseSet); ServiceRepository.Add(entityToAdd); return(Mapper.MapDALToBaseLiftSet(entityToAdd)); }
public async Task AddNewComment(CommentDTO dto) { var dal = new DAL.App.DTO.Comment() { AppUserId = dto.UserId, TrainingId = dto.TrainingId, Content = dto.Content, }; ServiceRepository.Add(dal); await ServiceUnitOfWork.SaveChangesAsync(); }
public async Task AddTrainingPlace(TrainingPlaceDTO dto) { var trainingPlace = new DAL.App.DTO.TrainingPlace() { Name = dto.Name, Address = dto.Address, OpeningTime = dto.OpeningTime, ClosingTime = dto.ClosingTime }; ServiceRepository.Add(trainingPlace); await ServiceUnitOfWork.SaveChangesAsync(); }
public void ServiceRepositoryDropAttemptsShouldRestart() { var serviceRepository = new ServiceRepository(); serviceRepository.Add(JabberService); Assert.AreEqual(true, serviceRepository.HasAtempt(JabberService)); var service = serviceRepository.GetService(JabberService); Assert.AreEqual(0, service.Attempt); Assert.AreEqual(false, serviceRepository.ShouldRestart(JabberService)); Assert.AreEqual(1, service.Attempt); serviceRepository.DropAttempt(JabberService); Assert.AreEqual(0, service.Attempt); }
/// <summary> /// Metoda sprawdza walidacje wartości pól dodaje nowy obiekt do bazy danych, czyści wartości pól oraz zamyka okno i odświeża widok Grida /// </summary> /// <param name="sender">Przycisk dodający zadnaie</param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (AreFieldsNullOrEmpty()) { MessageBox.Show("Uzupełnij wszystkie pola!"); return; } ServiceRepository sr = new ServiceRepository(); sr.Add(mtbDateFrom.Text, mtbDateTo.Text, tbService.Text, tbService.Text, Convert.ToInt32(tbPrize.Text), done, CarId); ClarTextValue(); var visit = new ServiceRepository().GetByCarId(CarId); dataGridView1.DataSource = visit; }
public void WcfService_CreateCustomerTest() { IRepository <Customer> customersRepository = new ServiceRepository <Customer>(); Customer customer = new Customer() { FName = "Dave" + DateTime.Now, LName = "Richardson", Address1 = "605 Sharview Cir", Address2 = "#1735", State = "NC", Country = "USA", Zipcode = "28217", Phone = "1234567890", Email = "*****@*****.**" }; var response = customersRepository.Add(customer); }
public async Task ChangeAnswer(NotificationAnswerDTO notificationAnswerDto) { var previousAnswer = await ServiceRepository.FirstOrDefaultAsync(notificationAnswerDto.id); previousAnswer.Attending = notificationAnswerDto.Coming; previousAnswer.Content = notificationAnswerDto.Content; var userInTraining = await ServiceUnitOfWork.UsersInTrainingRepository.FindByAppUserIdAndTrainingId( Guid.Parse(notificationAnswerDto.AppUserId), Guid.Parse(notificationAnswerDto.TrainingId)); if (notificationAnswerDto.Coming) { userInTraining.AttendingTraining = true; } ServiceRepository.Add(previousAnswer); await ServiceUnitOfWork.SaveChangesAsync(); }
public static void Add() { try { Service service = new Service(); Console.WriteLine("Please enter the following information:"); Console.Write("Name of service: "); service.NameOfService = Console.ReadLine(); while (string.IsNullOrWhiteSpace(service.NameOfService)) { Console.Write("Please enter correct name of service:"); service.NameOfService = Console.ReadLine(); } Console.Write("Price: "); string price = Console.ReadLine(); decimal decPrice = 0; while (!Decimal.TryParse(price, out decPrice)) { Console.WriteLine("Incorrect value! Please enter a valid price: "); price = Console.ReadLine(); } service.Price = decPrice; using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { ISalonManager <Service> serviceManager = new ServiceRepository(connection); Service addedService = serviceManager.Add(service); } Console.WriteLine($"Service {service.NameOfService} successfully added!"); } catch (Exception ex) { Console.WriteLine("Something went wrong... Try latter"); Console.WriteLine(ex.Message); } }
public async Task <App.DTO.TrainingWeek> AddNewWeekToBaseRoutineWithIdAsync(Guid routineId, bool isDeload) { var parentCycle = await UnitOfWork.TrainingCycles.FindWithBaseRoutineIdAsync(routineId); var trainingWeeks = (await UnitOfWork.TrainingWeeks.AllWithBaseRoutineIdAsync(routineId)).ToList(); var weekNumber = 1; if (trainingWeeks.Count != 0) { weekNumber += trainingWeeks.Max(w => w.WeekNumber); } var trainingWeek = new App.DTO.TrainingWeek { TrainingCycleId = parentCycle.Id, WeekNumber = weekNumber, IsDeload = isDeload }; ServiceRepository.Add(Mapper.MapBLLToDAL(trainingWeek)); return(trainingWeek); }
public UserTrainingDay Add(UserTrainingDay dto) { return(Mapper.MapDALToUserTrainingDay(ServiceRepository.Add(Mapper.MapUserTrainingDayToDALEntity(dto)))); }
public void ChooseActionForService() { ServiceRepository serviceRepository = new ServiceRepository(); ServiceServices serviceServices = new ServiceServices(); Console.Clear(); Console.WriteLine("Repository: SERVICE\n\n"); Console.WriteLine("What action you want to choose?\n" + "1. View table\n" + "2. Add row\n" + "3. Update row\n" + "4. Delete row\n" + "5. View maximum price\n" + "6. Viev minimum price\n" + "7. Back to start menu"); Console.Write("\nYour selection: "); string ch = Console.ReadLine(); switch (ch) { case "1": { try { Console.Clear(); Console.WriteLine("Repository: SERVICE\n\n"); serviceRepository.Select(serviceRepository.CreateFilter()); break; } finally { Menu menu = new Menu(); menu.ChooseActionForService(); } } case "2": { try { Console.Clear(); Console.WriteLine("Repository: SERVICE\n\n"); serviceRepository.Add(serviceRepository.CreateModel()); break; } finally { Menu menu = new Menu(); menu.ChooseActionForService(); } } case "3": { try { Console.Clear(); Console.WriteLine("Repository: SERVICE\n\n"); serviceRepository.Update(serviceRepository.CreateModel(), serviceRepository.CreateFilter()); break; } finally { Menu menu = new Menu(); menu.ChooseActionForService(); } } case "4": { try { Console.Clear(); Console.WriteLine("Repository: SERVICE\n\n"); serviceRepository.Delete(serviceRepository.CreateFilter()); break; } finally { Menu menu = new Menu(); menu.ChooseActionForService(); } } case "5": { try { Console.Clear(); Console.WriteLine("Repository: SERVICE\n\n"); Console.WriteLine("MaxPrice: " + serviceServices.MaxPrice()); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForService(); } } case "6": { try { Console.Clear(); Console.WriteLine("Repository: SERVICE\n\n"); Console.WriteLine("MinPrice: " + serviceServices.MinPrice()); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForService(); } } case "7": { Menu menu = new Menu(); menu.ChooseTable(); break; } default: Console.WriteLine("Invalid selection. Please select 1, 2, 3, 4 or 5."); break; } }