예제 #1
0
 public UnitOfWork(CoffeeShopContext context)
 {
     _context   = context;
     Offices    = new OfficeRepository(_context);
     Products   = new ProductRepository(_context);
     OrderItems = new OrderItemRepository(_context);
 }
예제 #2
0
        public void OfficeRepository_AddOffice_Added_NotFail_Test()
        {
            var context  = new MyCompanyContext();
            int expected = context.Offices.Count() + 1;

            var target = new OfficeRepository(context);

            var officeId   = context.Offices.Select(e => e.OfficeId).Max() + 1;
            var calendarId = context.Calendars.FirstOrDefault().CalendarId;
            var office     = new Office()
            {
                OfficeId   = officeId,
                CalendarId = calendarId
            };

            target.Add(office);

            int actual = context.Offices.Count();

            Assert.AreEqual(expected, actual);

            target.Delete(officeId);

            actual = context.Offices.Count();
            Assert.AreEqual(expected - 1, actual);
        }
예제 #3
0
        public static int?UpdateOffice(Office office)
        {
            if (office == null)
            {
                throw new System.ArgumentNullException()
                      {
                          Source = "office"
                      };
            }

            using (CustomClearviewEntities ctx = new CustomClearviewEntities())
            {
                OfficeRepository repo = new OfficeRepository(ctx);

                Office o = GetOffice(office.OfficeId);
                o.VendorId         = office.VendorId;
                o.OfficeName       = office.OfficeName;
                o.OfficeEmail      = office.OfficeEmail;
                o.MarketerCode     = office.MarketerCode;
                o.IsActive         = office.IsActive;
                o.ModifiedBy       = office.ModifiedBy;
                o.ModifiedDateTime = office.ModifiedDateTime;

                repo.Update(o);
                ctx.SaveChanges();
            }

            return(office.OfficeId);
        }
예제 #4
0
        ///<inheritdoc/>
        public override void Handle(BrokeredMessage message)
        {
            var officeRepository = new OfficeRepository(new MyCompanyContext());
            var dto    = message.GetBody <OfficeDTO>();
            var office = Mapper.Map <Office>(dto);

            officeRepository.Update(office);
        }
예제 #5
0
        public void OfficeRepository_UpdateOffice_NotFail_Test()
        {
            var context = new MyCompanyContext();
            var office  = context.Offices.FirstOrDefault();
            var target  = new OfficeRepository(context);

            office.CalendarId = context.Calendars.FirstOrDefault().CalendarId;
            target.Update(office);
        }
예제 #6
0
        public IActionResult UpdateQuantity(int id)
        {
            Product          product          = _dal.GetProduct(id);
            OfficeRepository officeRepository = _offDal.OfficeRepositories.Where(i => i.ProductID == id).Any() ? _offDal.GetOfficeRepositoryByProductID(id) : new OfficeRepository()
            {
                ID = 0, ProductID = product.ID, Product = product, Quantity = 0
            };

            return(View(officeRepository));
        }
예제 #7
0
        public AtiendemeUnitOfWork(ApplicationDbContext applicationDbContext, UserManager <ApplicationUser> userManager)
        {
            _applicationDbContext = applicationDbContext;

            DoctorRepository      = new DoctorRepository(_applicationDbContext, userManager);
            SpecialtiesRepository = new SpecialtiesRepository(_applicationDbContext);
            OfficeRepository      = new OfficeRepository(_applicationDbContext);
            ReservationRepository = new ReservationRepository(_applicationDbContext);
            UserRepository        = new UserRepository(_applicationDbContext, userManager);
        }
예제 #8
0
        public static Office GetOffice(int id)
        {
            Office office;

            using (CustomClearviewEntities ctx = new CustomClearviewEntities())
            {
                OfficeRepository repo = new OfficeRepository(ctx);
                office = repo.Find(x => x.OfficeId == id, type => type.Users, type => type.Vendor);
            }
            return(office);
        }
예제 #9
0
        public static List <Office> GetOffices(bool activeOnly, int vendorId)
        {
            List <Office> offices;

            using (CustomClearviewEntities ctx = new CustomClearviewEntities())
            {
                OfficeRepository repo = new OfficeRepository(ctx);
                offices = activeOnly
                    ? repo.Filter(v => v.VendorId == vendorId && v.IsActive, sort => sort.OfficeName, SortOrder.Ascending, type => type.Vendor, type => type.Users)
                    : repo.Filter(v => v.VendorId == vendorId, type => type.Vendor, type => type.Users);
            }
            return(offices);
        }
예제 #10
0
        public IActionResult UpdateQuantity(OfficeRepository officeRepository)
        {
            bool isExist = _offDal.OfficeRepositories.Where(i => i.ProductID == officeRepository.ProductID).Any();

            if (isExist)
            {
                int officeRepoID = _offDal.OfficeRepositories.Where(i => i.ProductID == officeRepository.ProductID).Select(o => o.ID).Single();
                officeRepository.ID = officeRepoID;
                _offDal.UpdateOfficeRepository(officeRepository);
            }
            else
            {
                officeRepository.ID = 0;
                _offDal.AddOfficeRepository(officeRepository);
            }
            return(RedirectToAction(nameof(List)));
        }
예제 #11
0
        public static int?CreateOffice(Office office)
        {
            if (office == null)
            {
                throw new System.ArgumentNullException()
                      {
                          Source = "office"
                      };
            }

            using (CustomClearviewEntities ctx = new CustomClearviewEntities())
            {
                OfficeRepository repo = new OfficeRepository(ctx);
                repo.Create(office);
                ctx.SaveChanges();
            }

            return(office.OfficeId);
        }
예제 #12
0
 public LoginController()
 {
     ContactRepository = new ContactRepository();
     OfficeRepository = new OfficeRepository();
     ProfileRepository = new ProfileRepository();
 }
예제 #13
0
파일: Program.cs 프로젝트: sirhazman07/HRMS
        static void Main(string[] args)
        {
            var db = new HRMSDBContext();

            //var employees = db.Employees.Include(e => e.EmployeeInPostions).Where(e => e.EmployeeInPostions.Any(eip => eip.PositionId == 2)).ToArray();
            //var customers = db.Customers.ToArray();
            //var products = db.Products.ToArray();
            var salesPL = db.SalePositionLeads.ToArray();
            var sales   = db.Sales.ToArray();
            var r       = new Random();

            foreach (var s in sales)
            {
                if (s.OrderNumber < 0)
                {
                    s.OrderNumber = s.OrderNumber * -1;
                }
                if (s.OrderNumber > 99)
                {
                    s.OrderNumber = r.Next(99);
                }
                db.SaveChanges();
                Console.WriteLine(s.OrderNumber);
            }

            foreach (var s in salesPL)
            {
                var b = r.Next(3);
                if (b == 1)
                {
                    s.FinalisedSale = true;
                    db.SaveChanges();
                    Console.WriteLine(s.FinalisedSale);
                }
            }

            //for (var start = new DateTime(2014, 07, 01); start < DateTime.Now; start = start.AddDays(r.Next(7)))
            //{
            //    var e = employees[r.Next(employees.Length)];
            //    var c = customers[r.Next(customers.Length)];

            //    var sale = new Sale { Date = start, OrderNumber = start.GetHashCode() };
            //    db.Sales.Add(sale);
            //    db.SaveChanges();

            //    var lead = new SaleLead { CustomerId = c.Id, SaleId = sale.Id, Timestamp = start.AddDays(-(r.NextDouble())), StateId = 1 };
            //    db.SaleLeads.Add(lead);
            //    db.SaveChanges();

            //    var employeeAssignedToLead = new SalePositionLead { SaleLeadId = lead.Id, EmployeeInSalePostionId = e.EmployeeInPostions.First(eip => eip.PositionId == 2).Id };
            //    db.SalePositionLeads.Add(employeeAssignedToLead);
            //    db.SaveChanges();

            //    for (int i = 0; i < r.Next(10); i++)
            //    {
            //        var p = products[r.Next(products.Length)];
            //        var item = new SaleLineItem { SaleId = sale.Id, ProductId = p.Id, Qty = r.Next(15), Amount = p.UnitPrice };
            //        db.SaleLineItems.Add(item);
            //    }
            //    db.SaveChanges();
            //    Console.WriteLine(start.ToString());

            //}


            //ICompanyRepository repoCompany = new CompanyRepository(db);

            //var company = new Company { ABN = "312", Name = "XYZ" };
            //repoCompany.Add(company);

            //var specification = new Specification<Company>(c => c.Id == 1);
            //specification.FetchStrategy.Include(c => c.People);
            //var company = repoCompany.Find(specification);

            //Company c2;
            //if (repoCompany.TryFind<Company>(specification, c => c, out c2))
            //{

            //}

            ////ref & out example
            //int i;
            //if (int.TryParse("21", out i))
            //{
            //    Console.WriteLine("It was a valid number, the number was: " + i);
            //}


            //load all of the sitting for the restaurant for the specified date
            //var spec = new Specification<Sitting>(s => s.RestaurantId == restaurantId && s.StartTime >= start && s.StartTime <= end);
            //spec.FetchStrategy.Include(s => s.Reservations).Include(s => s.Restaurant);
            //var sittings = _repoSitting.FindAll(spec);


            //Console.ReadKey();



            //TEAM D
            var repo     = new SupportStaffShiftRepository(db);
            var repoList = repo.AsQueryable().ToList();

            var emp = new EmployeeInPositionRepository(db);
            ////var emplist = emp.GetEmployeesInSupportPosition();

            var off = new OfficeRepository(db);

            ////var offlist = off.AsQueryable().ToList();


            //var service = new SupportStaffShiftService(repo,emp,off);
            //var serviceShiftList = service.AsQueryable().ToList();
            //var serviceShiftEmp = service.EmpInSuppPosAsQueryable().ToList();
            //var serviceShiftOff = service.OfficeAsQueryable().ToList();
            //var shifts = service.GetEmployeeShifts();

            Console.WriteLine("Hi");
        }
        ///<inheritdoc/>
        public override void Handle(BrokeredMessage message)
        {
            var officeRepository = new OfficeRepository(new MyCompanyContext());

            officeRepository.Delete(message.GetBody <int>());
        }
예제 #15
0
 public OfficeApiService(OfficeRepository repository)
 {
     _repository = repository;
 }
예제 #16
0
 public OfficeUnitOfWork(IMapper mapper, OfficeRepository repository)
 {
     _mapper     = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _repository = repository ?? throw new ArgumentNullException(nameof(repository));
 }
예제 #17
0
        public List <string> GetOfficeList()
        {
            OfficeRepository office = new OfficeRepository();

            return(office.GetListOffice());
        }