コード例 #1
0
        public CheckoutDto CreateCheckout(CreateCheckoutDto data, StaffMemberDto staffMemberDto, JobDto jobDto)
        {
            Checkout checkout = new Checkout(Mapper.Map <StaffMember>(staffMemberDto), data.ShiftDate, Mapper.Map <Job>(jobDto));

            if (_repository.CheckoutExists(data.ShiftDate, staffMemberDto.Id, data.LunchOrDinner))
            {
                throw new InvalidOperationException("A checkout for this employee already exists for this day and shift.");
            }
            Mapper.Map(data, checkout);
            CheckoutEntity checkOutEntity = Mapper.Map <CheckoutEntity>(checkout);

            _repository.AddCheckOut(checkOutEntity);

            _repository.VerifyDatabaseSaveSuccess();
            return(Mapper.Map <CheckoutDto>(checkOutEntity));
        }