public async Task <PagingDataSource <Staff> > Get(ODataQueryOptions <Staff> options, [FromUri] StaffList req) { StaffService.DisableProxy(); var litStaff = StaffService.GetAll(); if (req != null) { if (req.Includes != null && req.Includes.Length > 0) { litStaff = Include(litStaff, req.Includes); } if (req.PositionId > 0) { litStaff = litStaff.Where(o => o.PositionId == req.PositionId); } } var ls = (IQueryable <Staff>)options.ApplyTo(litStaff); var retVal = new PagingDataSource <Staff>(); retVal.Data = await ls.Cast <Staff>().ToListAsync(); retVal.Total = Request.GetInlineCount() ?? 0; return(retVal); }
static void Main(string[] args) { //Here is a small project which prints out a list of customers to the Output window. //It's the beginning of a sales system which stores the details of customers and staff members. //This project will compile and run but the code is in need of refactoring because breaches the principles of Clean Code and SOLID. //Please read, run and experiment with it as much as you require and refactor it to the best of your ability to make it less esoteric and more maintainable. //You can change any of the code in this project apart from the section marked 'Code that must not change' //N.B. The output of the code must not change var customerService = new CustomerService(); var staffService = new StaffService(); customerService.Add(CustomerService.GetDefault()); customerService.Add(new Customer(customerService.GetIndex(), "Emma", CustomerType.New)); customerService.Add(new Customer(customerService.GetIndex(), "James", CustomerType.Existing)); customerService.Add(new Customer(customerService.GetIndex(), "Ricardo", CustomerType.New)); customerService.Add(new Customer(customerService.GetIndex(), "Paul", CustomerType.Archived)); staffService.Add(StaffService.GetDefault()); staffService.Add(new StaffMember(staffService.GetIndex(), "Dave", StaffMemberType.Existing)); staffService.Add(new StaffMember(staffService.GetIndex(), "Penny", StaffMemberType.Archived)); staffService.Add(new StaffMember(staffService.GetIndex(), "Dan", StaffMemberType.New)); staffService.Add(new StaffMember(staffService.GetIndex(), "Mark", StaffMemberType.Existing)); var customers = customerService.GetAll(); var staffMembers = staffService.GetAll(); // In order to Make a sale use OrderService Class and CreateOrder method, // Normaly this parameters will be injected using dependency injeciton var orderService = new OrderService(staffService, customerService); orderService.CreateOrder(customers.FirstOrDefault().ID, staffMembers.FirstOrDefault().ID, null); Debug.Print($"\r\n{AppHelper.GetApplicationName()}:"); ///////////////////////////// //Code that must not change// ///////////////////////////// foreach (var customer in customers) { Debug.Print($"Customer name: {PersonHelper.GetPersonName(customer)} - List Order: {customer.Index} - Customer Type: {PersonHelper.GetPersonType(customer)}"); } foreach (var staffMember in staffMembers) { Debug.Print($"Staff Member name: {PersonHelper.GetPersonName(staffMember)} - List Order: {staffMember.Index} - Staff Member Type: {PersonHelper.GetPersonType(staffMember)}"); } ///////////////////////////////// //end code that must not change// ///////////////////////////////// Console.ReadLine(); }
public ActionResult Index() { try { var staffMembers = _staffService.GetAll(); return(View(staffMembers)); } catch { return(View()); } }
// GET: api/Staff public IEnumerable <StaffDto> Get() { try { return(service.GetAll().Select(e => new StaffDto(e))); } catch (Exception) { throw; } }
public async Task <object> Delete(int staffId) { if (staffId > 0) { var staff = await StaffService.GetAll().Where(o => o.StaffId == staffId).FirstOrDefaultAsync(); if (staff != null) { await StaffService.DeleteAsync(staff); } else { throw new ApiException("Nhân viên không tồn tại"); } } else { throw new ApiException("Nhân viên không tồn tại"); } return(new { Message = "Xóa Nhân viên thành công" }); }
public IEnumerable <Staff> GetAll() { return(staffService.GetAll()); }
public IEnumerable <StaffDTO> ListStaff() { return(_staffService.GetAll()); }
public ActionResult <IList <Salon> > Get() { return(staffService.GetAll().ToArray()); }
public IEnumerable <Staff> Get() => _staffService.GetAll();