public ActionResult Detail(Service service) { if (!ModelState.IsValid) { var model = new ServiceModel() { Service = service, ServiceTypes = EnumCollection.GetServiceTypeEnum() }; return(View(model)); } var result = ServiceTypeService.Save(service); if (result.HasError) { ViewBag.Error = result.Message; var model = new ServiceModel() { Service = service, ServiceTypes = EnumCollection.GetServiceTypeEnum() }; return(View(model)); } return(RedirectToAction("List")); }
public ActionResult Delete(int id) { var result = ServiceTypeService.Delete(id); if (!result) { TempData["Error"] = "Something went wrong"; } return(RedirectToAction("List")); }
public void ConstructorIsValid() { try { var service = new ServiceTypeService(_repository); } catch (Exception e) { Assert.Fail(e.ToString()); } }
// // GET: /AdminService/ public ActionResult List() { var model = ServiceTypeService.GetAll(); if (TempData["Error"] != null) { ViewBag.Error = TempData["Error"]; } return(View(model)); }
public void Initialize() { var serviceTypes = GetFakeData(); _dbContextMock = new DbContextMock <DatabaseContext>(DummyOptions); var dbSetMock = _dbContextMock.CreateDbSetMock(x => x.ServiceTypes, serviceTypes); var repository = new ServiceTypeRepository(_dbContextMock.Object); _service = new ServiceTypeService(repository); }
public ActionResult Index2(int id = -1) { if (id == -1) { id = 1; } ViewBag.ID = id; ViewBag.Services = ServiceTypeService.GetAll(); return(View()); }
public ActionResult Detail(int id) { var result = ServiceTypeService.GetByID(id); var model = new ServiceModel() { Service = result.Data ?? new Service(), ServiceTypes = EnumCollection.GetServiceTypeEnum() }; return(View(model)); }
public async Task GetServiceTypeAsync_Returns_Null() { //Arrange var id = 10; var service = new ServiceTypeService(_myRestaurantContext); //Act var result = await service.GetServiceTypeAsync(d => d.Id == id); //Assert result.Should().BeNull(); }
public async Task GetServiceTypesAsync_Returns_ServiceTypes() { //Arrange var service = new ServiceTypeService(_myRestaurantContext); //Act var result = await service.GetServiceTypesAsync(); //Assert result.Should().BeAssignableTo <IEnumerable <ServiceType> >(); result.Should().HaveCount(2); }
public async Task GetServiceTypeAsync_Returns_ServiceType() { //Arrange var id = 1; var service = new ServiceTypeService(_myRestaurantContext); //Act var result = await service.GetServiceTypeAsync(d => d.Id == id); //Assert result.Should().BeAssignableTo <ServiceType>(); result !.Id.Should().Be(id); result.Type.Should().Be("Take Away"); }
public static IEnumerable <SelectListItem> FillddlServiceType() { var service = new ServiceTypeService(); var leaveTypes = service.GetAll(); var listitems = leaveTypes.Select(x => new SelectListItem { Text = x.ServiceName, Value = x.Id.ToString() }); return(listitems); }
public async Task DeleteServiceTypeAsync_Successfully_Deleted() { //Arrange var id = 1; var service = new ServiceTypeService(_myRestaurantContext); //Act var dbServiceType = await service.GetServiceTypeAsync(d => d.Id == id); await service.DeleteServiceTypeAsync(dbServiceType !); var result = await service.GetServiceTypeAsync(d => d.Id == id); //Assert result.Should().BeNull(); }
private void btnXoa_Click(object sender, EventArgs e) { if (DialogResult.OK == XtraMessageBox.Show("Bạn muốn xóa dịch vụ ra khỏi hệ thống ?", "Xác nhận", MessageBoxButtons.OKCancel)) { bool rs = serviceType.Delete(_PartnerID); if (rs) { serviceType = new ServiceTypeService(); gridDataControl.DataSource = serviceType.GetList(_TourID); } else { XtraMessageBox.Show("Không tìm thấy thông tin"); } } }
public DashboardModel GetPosts2() { var model = new DashboardModel() { Labels = new List <string>(), Datas = new List <int>() }; var services = ServiceTypeService.GetPostCount(); foreach (var s in services) { model.Labels.Add(s.Name); model.Datas.Add(s.ServiceTypeID); } return(model); }
public async Task AddServiceTypeAsync_Returns_New_ServiceType() { //Arrange var service = new ServiceTypeService(_myRestaurantContext); //Act var result = await service.AddServiceTypeAsync(new ServiceType { Type = "Buffet" }); //Assert result.Should().BeAssignableTo <ServiceType>(); result.Type.Should().Be("Buffet"); //Act var stockTypes = await service.GetServiceTypesAsync(); //Assert stockTypes.Should().HaveCount(3); }
public async Task UpdateServiceTypeAsync_Successfully_Updated() { //Arrange var id = 1; var service = new ServiceTypeService(_myRestaurantContext); //Act var dbServiceType = await service.GetServiceTypeAsync(d => d.Id == id); dbServiceType !.Type = "Take Out"; await service.UpdateServiceTypeAsync(dbServiceType); var result = await service.GetServiceTypeAsync(d => d.Id == id); //Assert result.Should().BeAssignableTo <ServiceType>(); result !.Id.Should().Be(id); result.Type.Should().Be("Take Out"); }
public DashboardModel GetPosts2ByCurrentUser() { var model = new DashboardModel() { Labels = new List <string>(), Datas = new List <int>() }; if (HttpUtil.UserProfile == null) { return(model); } var list = PostService.GetAllByUserId(HttpUtil.UserProfile.ID); var services = ServiceTypeService.GetAll(); foreach (var s in services) { model.Labels.Add(s.Name); model.Datas.Add(list.Count(l => l.ServiceID == s.ID)); } return(model); }
public ServiceTypesController() { Service = new ServiceTypeService(); }
public ServiceTypesController(ServiceTypeService service) { _service = service; }
private void loadData() { serviceType = new ServiceTypeService(); gridDataControl.DataSource = serviceType.GetList(_TourID); }
public static IEnumerable<SelectListItem> FillddlServiceType() { var service = new ServiceTypeService(); var leaveTypes = service.GetAll(); var listitems = leaveTypes.Select(x => new SelectListItem { Text = x.ServiceName, Value = x.Id.ToString() }); return listitems; }
public List <Service> GetAllServices() { return(ServiceTypeService.GetAll()); }