public ActionResult Create([Bind(Include = "bookingCode,description")] BookingType bookingType)
        {
            if (Session["currentUser"] == null)
            {
                TempData["message"] = "Please login to continue.";
                return(RedirectToAction("VerifyLogin"));
            }
            if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1)
            {
                TempData["message"] = "You must be an administrator to access this page.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    db.BookingTypes.Add(bookingType);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            catch
            {
                TempData["Message"] = "ERROR - Please try again";
                return(View());
            }

            return(View(bookingType));
        }
예제 #2
0
        public static BookingEventType GetBookingEventStatus(BookingType bookingType, DateTime startTime,
          BookingStatus bookingStatus, string shortDescription)
        {
            if (shortDescription == TeleConsult.Infrastructure.Core.Const.AlertShortDescription
                    .FileUploadedToBookingByConsultant.ToString()
                || shortDescription == TeleConsult.Infrastructure.Core.Const.AlertShortDescription
                    .FileUploadedToBookingByCustomer.ToString())
            {
                return BookingEventType.Photo;
            }
            else if (bookingStatus == BookingStatus.Requested
                || bookingStatus == BookingStatus.SpecialistRescheduled
                || bookingStatus == BookingStatus.CustomerRescheduled)
            {
                if (bookingStatus == BookingStatus.Requested
                    && bookingType == BookingType.ASAP
                    && (DateTime.UtcNow - startTime).Hours > ConfigurationData.ASAPBookingExpiredTime())
                {
                    return BookingEventType.Past;
                }
                return BookingEventType.Request;
            }
            else if (bookingStatus == BookingStatus.Confirmed)
            {
                return BookingEventType.Confirmed;
            }
            else if (bookingStatus == BookingStatus.Cancel
                || bookingStatus == BookingStatus.Finish)
            {
                return BookingEventType.Past;
            }

            return BookingEventType.InProgress;
        }
예제 #3
0
        internal void CreatePayments(Booking booking, PaymentController paymentController)
        {
            Supplier    supplier    = (Supplier)booking.Supplier;
            Customer    customer    = (Customer)booking.Customer;
            BookingType bookingType = booking.Type;

            List <IPaymentRule> paymentRules = findMatchingPaymentRules(supplier, customer, bookingType);

            foreach (IPaymentRule paymentRule in paymentRules)
            {
                DateTime dueDate;

                if (paymentRule.BaseDate == BaseDate.StartDate)
                {
                    dueDate = booking.StartDate.AddDays(paymentRule.DaysOffset);
                }
                else
                {
                    dueDate = booking.EndDate.AddDays(paymentRule.DaysOffset);
                }

                booking.CalculateAmounts();
                decimal dueAmount = booking.TransferAmount * paymentRule.Percentage / 100;

                Customer lonelyTree = customerController.findLonelyTree();

                IPayment payment = paymentController.CreatePayment(dueDate, dueAmount, lonelyTree, booking.Supplier,
                                                                   paymentRule.PaymentType, booking.Sale, booking.BookingNumber);

                paymentController.UpdatePayment(payment);
            }
        }
예제 #4
0
        protected override PaymentRuleEntity entityFromReader(SqlDataReader reader)
        {
            int            supplierId  = (int)reader["Supplier"];
            int            customerId  = (int)reader["Customer"];
            SupplierEntity supplier    = SupplierMapper.Read(supplierId);
            CustomerEntity customer    = CustomerMapper.Read(customerId);
            BookingType    bookingType = (BookingType)Enum.Parse(typeof(BookingType), reader["BookingType"].ToString());
            decimal        percentage  = (decimal)reader["Percentage"];
            int            daysOffset  = (int)reader["DaysOffset"];
            BaseDate       baseDate    = (BaseDate)Enum.Parse(typeof(BaseDate), reader["BaseDate"].ToString());
            PaymentType    paymentType = (PaymentType)Enum.Parse(typeof(PaymentType), reader["PaymentType"].ToString());

            PaymentRuleEntity paymentRuleEntity = new PaymentRuleEntity(supplier, customer, bookingType, percentage,
                                                                        daysOffset, baseDate, paymentType);

            int      paymentRuleId = (int)reader["PaymentRuleId"];
            DateTime lastModified  = (DateTime)reader["LastModified"];
            bool     deleted       = (bool)reader["Deleted"];

            paymentRuleEntity.Id           = paymentRuleId;
            paymentRuleEntity.LastModified = lastModified;
            paymentRuleEntity.Deleted      = deleted;

            supplier.AddPaymentRule(paymentRuleEntity);

            return(paymentRuleEntity);
        }
예제 #5
0
 // Creates a booking
 public Booking(int orderID, string location, BookingType type)
 {
     OrderID         = orderID;
     Location        = location;
     Type            = type.ToString();
     ReferenceNumber = GenerateReferenceNumber();
 }
 public Booking(BookingType bookingType, uint numOfNights, bool brealfastInTheMorning)
 {
     this.bookingType      = bookingType;
     NumOfNights           = numOfNights;
     BrealfastInTheMorning = brealfastInTheMorning;
     total = CalculateTotal();
 }
예제 #7
0
        public async Task GetBookings_ReturnsAllWalks()
        {
            BookingType bookingType = BookingType.Walk;
            var         walks       = await _sut.GetBookingsAsync(bookingType);

            walks.Should().BeEmpty();
        }
예제 #8
0
 public Booking(
     BookingId id,
     DateTime startDate,
     DateTime endDate,
     CustomerId customerId,
     CustomerName customerName,
     EmailAddress customerEmail,
     BookingType bookingType,
     DiscountType discountType,
     DiscountValue discountValue,
     TaxType taxType,
     TaxValue taxValue
     )
 {
     this.id            = id;
     this.startDate     = startDate;
     this.endDate       = endDate;
     this.customerId    = customerId;
     this.customerName  = customerName;
     this.customerEmail = customerEmail;
     this.bookingType   = bookingType;
     this.discountType  = discountType;
     this.discountValue = discountValue;
     this.taxType       = taxType;
     this.taxValue      = taxValue;
 }
예제 #9
0
        public void AddPaymentRule(ISupplier supplier, ICustomer customer, BookingType bookingType, decimal percentage,
            int daysOffset, BaseDate baseDate, PaymentType paymentType)
        {
            Supplier supp = (Supplier)supplier;
            Customer cust = (Customer)customer;

            supp.AddPaymentRule(cust, bookingType, percentage, daysOffset, baseDate, paymentType);
        }
예제 #10
0
        // TB
        #region Public PaymentRule Methods
        public IPaymentRule CreatePaymentRule(ISupplier supplierEntity, ICustomer customerEntity,
                                              BookingType bookingType, decimal percentage, int daysOffset, BaseDate baseDate, PaymentType paymentType)
        {
            SupplierEntity s = (SupplierEntity)supplierEntity;
            CustomerEntity c = (CustomerEntity)customerEntity;

            return(paymentRuleMapper.Create(s, c, bookingType, percentage, daysOffset, baseDate, paymentType));
        }
예제 #11
0
        public ActionResult DeleteConfirmed(int id)
        {
            BookingType bookingType = db.BookingTypes.Find(id);

            db.BookingTypes.Remove(bookingType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #12
0
        internal void AddPaymentRule(Customer customer, BookingType bookingType, decimal percentage, int daysOffset,
                                     BaseDate baseDate, PaymentType paymentType)
        {
            PaymentRule paymentRule = new PaymentRule(this, customer, bookingType, percentage, daysOffset, baseDate,
                                                      paymentType, dataAccessFacade);

            readPaymentRules();
        }
예제 #13
0
        public void AddPaymentRule(ISupplier supplier, ICustomer customer, BookingType bookingType, decimal percentage,
                                   int daysOffset, BaseDate baseDate, PaymentType paymentType)
        {
            Supplier supp = (Supplier)supplier;
            Customer cust = (Customer)customer;

            supp.AddPaymentRule(cust, bookingType, percentage, daysOffset, baseDate, paymentType);
        }
예제 #14
0
 public Booking(TimeSlot Time, List<Room> Rooms, Subject Subject, List<Student> Students, Teacher Teacher, BookingType BookingType)
 {
     TimeSlot = Time;
     this.Rooms = Rooms;
     this.Subject = Subject;
     this.Students = Students;
     this.Teacher = Teacher;
     this.BookingType = BookingType;
 }
        public void CreateCreditDebit(GrossNetType grossNetType, BookingType bookingType, decimal amount, CostAccount costAccountCreditor, CostAccount costAccountDebitor, TaxType taxType, out List <Credit> credits, out List <Debit> debits)
        {
            credits = new List <Credit>();
            debits  = new List <Debit>();

            if (costAccountCreditor == null || costAccountDebitor == null)
            {
                return;
            }

            CalculateTax(grossNetType, taxType, amount, out decimal tax, out decimal amountWithoutTax);

            Debit  debit  = new Debit();
            Credit credit = new Credit();

            TaxType nonTax = TaxTypes.GetById(1);

            if (bookingType == BookingType.Invoice)
            {
                if (taxType.Description.IndexOf("Vorsteuer", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    credits.AddRange(CreateCredits(grossNetType, nonTax, tax + amountWithoutTax, costAccountCreditor));
                    debits.AddRange(CreateDebits(grossNetType, taxType, amount, costAccountDebitor));
                }
                else if (taxType.Description.IndexOf("Umsatzsteuer", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    credits.AddRange(CreateCredits(grossNetType, taxType, amount, costAccountCreditor));
                    debits.AddRange(CreateDebits(grossNetType, nonTax, tax + amountWithoutTax, costAccountDebitor));
                }
                else
                {
                    credits.AddRange(CreateCredits(grossNetType, nonTax, amount, costAccountCreditor));
                    debits.AddRange(CreateDebits(grossNetType, nonTax, amount, costAccountDebitor));
                }
            }
            else if (bookingType == BookingType.CreditAdvice)
            {
                // ToDo Check with Tobias !!!

                if (taxType.Description.IndexOf("Vorsteuer", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    credits.AddRange(CreateCredits(grossNetType, nonTax, amount * (-1), costAccountCreditor));
                    debits.AddRange(CreateDebits(grossNetType, taxType, amount, costAccountDebitor));
                }
                else if (taxType.Description.IndexOf("Umsatzsteuer", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    credits.AddRange(CreateCredits(grossNetType, taxType, amount, costAccountCreditor));
                    debits.AddRange(CreateDebits(grossNetType, nonTax, amount * (-1), costAccountDebitor));
                }
                else
                {
                    credits.AddRange(CreateCredits(grossNetType, nonTax, amount, costAccountCreditor));
                    debits.AddRange(CreateDebits(grossNetType, nonTax, amount * (-1), costAccountDebitor));
                }
            }
        }
예제 #16
0
        public bool Save()
        {
            BookingType type    = Factory.getType(b.Checked);
            bool        getType = type.type(b.Checked);

            Session ses = new Session(int.Parse(sessionID.Text.ToString()), int.Parse(staffID.Text.ToString()), int.Parse(Slope.Text.ToString()), Convert.ToDateTime(date.Text), Convert.ToDateTime(StartTime.Text), Convert.ToDateTime(EndTime.Text), getType);
            bool    i   = ses.Update();

            return(i);
        }
예제 #17
0
 public ActionResult Edit([Bind(Include = "BookingTypeID,BookingTypeDescription")] BookingType bookingType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bookingType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bookingType));
 }
예제 #18
0
        public ActionResult Create([Bind(Include = "BookingTypeID,BookingTypeDescription")] BookingType bookingType)
        {
            if (ModelState.IsValid)
            {
                db.BookingTypes.Add(bookingType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bookingType));
        }
예제 #19
0
        public IPaymentRule CreatePaymentRule(ISupplier supplierEntity, ICustomer customerEntity, 
            BookingType bookingType, decimal percentage, int daysOffset, BaseDate baseDate, PaymentType paymentType)
        {
            PaymentRuleEntity paymentRule = new PaymentRuleEntity(supplierEntity, customerEntity, bookingType,
                percentage, daysOffset, baseDate, paymentType);

            SupplierEntity supplier = (SupplierEntity)supplierEntity;
            supplier.AddPaymentRule(paymentRule);

            return paymentRule;
        }
예제 #20
0
 internal PaymentRuleEntity(ISupplier supplierEntity, ICustomer customerEntity, BookingType bookingType,
                            decimal percentage, int daysOffset, BaseDate baseDate, PaymentType paymentType)
 {
     Supplier    = supplierEntity;
     Customer    = customerEntity;
     BookingType = bookingType;
     Percentage  = percentage;
     DaysOffset  = daysOffset;
     BaseDate    = baseDate;
     PaymentType = paymentType;
 }
예제 #21
0
 internal PaymentRuleEntity(ISupplier supplierEntity, ICustomer customerEntity, BookingType bookingType,
     decimal percentage, int daysOffset, BaseDate baseDate, PaymentType paymentType)
 {
     Supplier = supplierEntity;
     Customer = customerEntity;
     BookingType = bookingType;
     Percentage = percentage;
     DaysOffset = daysOffset;
     BaseDate = baseDate;
     PaymentType = paymentType;
 }
예제 #22
0
        public IPaymentRule CreatePaymentRule(ISupplier supplierEntity, ICustomer customerEntity,
                                              BookingType bookingType, decimal percentage, int daysOffset, BaseDate baseDate, PaymentType paymentType)
        {
            PaymentRuleEntity paymentRule = new PaymentRuleEntity(supplierEntity, customerEntity, bookingType,
                                                                  percentage, daysOffset, baseDate, paymentType);

            SupplierEntity supplier = (SupplierEntity)supplierEntity;

            supplier.AddPaymentRule(paymentRule);

            return(paymentRule);
        }
예제 #23
0
        internal PaymentRuleEntity Create(SupplierEntity supplierEntity, CustomerEntity customerEntity,
                                          BookingType bookingType, decimal percentage, int daysOffset, BaseDate baseDate, PaymentType paymentType)
        {
            PaymentRuleEntity paymentRuleEntity = new PaymentRuleEntity(supplierEntity, customerEntity, bookingType,
                                                                        percentage, daysOffset, baseDate, paymentType);

            insert(paymentRuleEntity);

            // could be done in PaymentRuleEntity constructor? Almost Inversion Of Control!
            supplierEntity.AddPaymentRule(paymentRuleEntity);

            return(paymentRuleEntity);
        }
예제 #24
0
        // Derived constructor to handle the common tasks of the above two constructors
        public EditBooking(User CurrentUser, bool NewBooking, int Id, List <Room> SelectedRooms, Room StartRoom, TimeSlot TimeSlot, List <Student> SelectedStudents, Subject Subject, Teacher Teacher, BookingType BookingType) // For editing an existing booking
        {
            // Store necessary data
            this.CurrentUser    = CurrentUser;
            SelectedBookingType = BookingType;
            BookingId           = Id;
            DeleteBooking       = false;
            SelectedTimeslot    = TimeSlot;

            using (DataRepository Repo = new DataRepository())
            {
                // Store the rooms
                Rooms = new ObservableCollection <Checkable <Room> >(Repo.Rooms.ToList().Select(r1 => new Checkable <Room>(r1, (StartRoom != null && r1.Id == StartRoom.Id) || SelectedRooms.Any(r2 => r1.Id == r2.Id))));
                // Store the timeslots
                Periods = new ObservableCollection <TimeSlot>(Repo.Periods);

                // Store the subjects
                Subjects = Repo.Subjects.ToList();
                if (Subject != null) // Initialise if needed
                {
                    SelectedSubject = Subject;
                }

                // Store teacher list
                Teachers = Repo.Users.OfType <Teacher>().ToList();
                if (Teacher != null) // Initialise if needed
                {
                    SelectedTeacher = Teacher;
                }
                else if (CurrentUser is Teacher) // Else give default value
                {
                    SelectedTeacher = (Teacher)CurrentUser;
                }
            }

            // Initialise the UI
            InitializeComponent();

            // Perform initial selection of students
            StudentSelector.Students.Where(s => SelectedStudents.Contains(s.Value)).ToList().ForEach(s => s.Checked = true);

            if (!CurrentUser.IsAdmin) // Only let the teacher be changed if the user is an admin
            {
                Combo_Teacher.IsEnabled = false;
            }

            if (NewBooking) // Must be editing a booking to delete it
            {
                Button_Delete.IsEnabled = false;
            }
        }
예제 #25
0
 //constructor
 public BookingConfiguration(BookingType booktype, string hotelName, string arrivalMonth, string arrivalDay, string duration,
                             int numberOfRooms, int room1Adults, int room1Children, int room1Infants, PropertySource source)
 {
     BookType              = booktype;
     HotelName             = hotelName;
     ArrivalMonth          = arrivalMonth;
     ArrivalDay            = arrivalDay;
     Duration              = duration;
     NumberOfRooms         = numberOfRooms;
     NumberOfAdultsRoom1   = room1Adults;
     NumberOfChildrenRoom1 = room1Children;
     NumberOfInfantsRoom1  = room1Infants;
     Source = source;
 }
예제 #26
0
        // GET: BookingTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BookingType bookingType = db.BookingTypes.Find(id);

            if (bookingType == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingType));
        }
예제 #27
0
        private ReservationType MapType(BookingType type)
        {
            switch (type)
            {
            case BookingType.Event: return(ReservationType.Event);

            case BookingType.Group: return(ReservationType.Group);

            case BookingType.RackRate: return(ReservationType.RackRate);

            case BookingType.Usual: return(ReservationType.Usual);

            default: return(ReservationType.Usual);
            }
        }
예제 #28
0
        internal PaymentRule(Supplier supplier, Customer customer, BookingType bookingType, decimal percentage, 
            int daysOffset, BaseDate baseDate, PaymentType paymentType, IDataAccessFacade dataAccessFacade)
        {
            // validate
            validateCustomer(customer);
            validateSupplier(supplier);

            // Get entities for DataAccess
            ISupplier supplierEntity = supplier._supplierEntity;
            ICustomer customerEntity = customer._customerEntity;

            this.dataAccessFacade = dataAccessFacade;
            _paymentRuleEntity = dataAccessFacade.CreatePaymentRule(supplierEntity, customerEntity, bookingType,
                percentage, daysOffset, baseDate, paymentType);
        }
예제 #29
0
        internal PaymentRule(Supplier supplier, Customer customer, BookingType bookingType, decimal percentage,
                             int daysOffset, BaseDate baseDate, PaymentType paymentType, IDataAccessFacade dataAccessFacade)
        {
            // validate
            validateCustomer(customer);
            validateSupplier(supplier);

            // Get entities for DataAccess
            ISupplier supplierEntity = supplier._supplierEntity;
            ICustomer customerEntity = customer._customerEntity;

            this.dataAccessFacade = dataAccessFacade;
            _paymentRuleEntity    = dataAccessFacade.CreatePaymentRule(supplierEntity, customerEntity, bookingType,
                                                                       percentage, daysOffset, baseDate, paymentType);
        }
예제 #30
0
 public Booking(
     BookingId id,
     DateRange dateRange,
     Customer customer,
     BookingType bookingType,
     Discount discount,
     Tax tax
     )
 {
     this.id          = id;
     this.dateRange   = dateRange;
     this.customer    = customer;
     this.bookingType = bookingType;
     this.discount    = discount;
     this.tax         = tax;
 }
예제 #31
0
        static public BookingType getType(bool i)
        {
            BookingType type = null;

            switch (i)
            {
            case false:
                type = new Individual();
                break;

            case true:
                type = new Group();
                break;
            }
            return(type);
        }
예제 #32
0
        private List<IPaymentRule> findMatchingPaymentRules(Supplier supplier, Customer customer, BookingType bookingType)
        {
            IReadOnlyList<IPaymentRule> suppliersPaymentRules = supplier.PaymentRules;
            List<IPaymentRule> paymentRulesForCustomer = findPaymentRulesForCustomer(suppliersPaymentRules, customer);
            if (paymentRulesForCustomer.Count == 0)
            {
                Customer anyCustomer = customerController.findAnyCustomer();
                paymentRulesForCustomer = findPaymentRulesForCustomer(suppliersPaymentRules, anyCustomer);
            }
            List<IPaymentRule> paymentRulesForBookingType = findPaymentRulesForBookingType(paymentRulesForCustomer, bookingType);
            if (paymentRulesForBookingType.Count == 0)
            {
                paymentRulesForBookingType = findPaymentRulesForBookingType(paymentRulesForCustomer, BookingType.Undefined);
            }

            return paymentRulesForBookingType;
        }
예제 #33
0
        public async Task <bool> AddNewBookingType(AddNewBookingTypeBindingModel bindingModel)
        {
            var name       = bindingModel.Name;
            var isPaid     = bindingModel.IsPaidTimeOff;
            var isSubtract = bindingModel.IsSubtractDaysLeft;

            var bookingType = new BookingType();

            bookingType.Name               = name;
            bookingType.IsPaidTimeOff      = isPaid;
            bookingType.IsSubtractDaysLeft = isSubtract;

            this.dbContext.BookingTypes.Add(bookingType);
            var result = await dbContext.SaveChangesAsync();

            return(result > 0);
        }
예제 #34
0
        protected override BookingEntity entityFromReader(SqlDataReader reader)
        {
            //Sets data from the database to corresponding data type for usage in the program.
            int         supplierId        = (int)reader["Supplier"];
            int         customerId        = (int)reader["Customer"];
            string      note              = (string)reader["Note"];
            string      sale              = (string)reader["Sale"];
            int         bookingNumber     = (int)reader["BookingNumber"];
            DateTime    startDate         = (DateTime)reader["StartDate"];
            DateTime    endDate           = (DateTime)reader["EndDate"];
            BookingType type              = (BookingType)Enum.Parse(typeof(BookingType), reader["Type"].ToString());
            decimal     iVAExempt         = (decimal)reader["IVAExempt"];
            decimal     iVASubject        = (decimal)reader["IVASubject"];
            decimal     service           = (decimal)reader["Service"];
            decimal     iVA               = (decimal)reader["IVA"];
            decimal     productRetention  = (decimal)reader["ProductRetention"];
            decimal     supplierRetention = (decimal)reader["supplierRetention"];
            decimal     transferAmount    = (decimal)reader["TransferAmount"];

            int      id           = (int)reader["BookingId"];
            DateTime lastModified = (DateTime)reader["LastModified"];
            bool     deleted      = (bool)reader["Deleted"];

            SupplierEntity supplier = SupplierMapper.Read(supplierId);
            CustomerEntity customer = CustomerMapper.Read(customerId);

            BookingEntity bookingEntity = new BookingEntity(supplier, customer, sale, bookingNumber,
                                                            startDate, endDate);

            //Uses the data to make it into an booking object.
            bookingEntity.Note              = note;
            bookingEntity.Id                = id;
            bookingEntity.LastModified      = lastModified;
            bookingEntity.Deleted           = deleted;
            bookingEntity.Type              = type;
            bookingEntity.IVAExempt         = iVAExempt;
            bookingEntity.IVA               = iVA;
            bookingEntity.IVASubject        = iVASubject;
            bookingEntity.Service           = service;
            bookingEntity.ProductRetention  = productRetention;
            bookingEntity.SupplierRetention = supplierRetention;
            bookingEntity.TransferAmount    = transferAmount;

            return(bookingEntity);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["currentUser"] == null)
            {
                TempData["message"] = "Please login to continue.";
                return(RedirectToAction("VerifyLogin"));
            }
            if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1)
            {
                TempData["message"] = "You must be an administrator to access this page.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            BookingType bookingType = db.BookingTypes.Find(id);

            db.BookingTypes.Remove(bookingType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #36
0
 public Booking(BookingType bookingtype, string bookedby, string title, string description)
 {
     if(bookingtype == BookingType.NotBooked)
     {
         booked_ = false;
         bookedBy_ = "";
         description_ = "";
         title_ = "";
         type_ = BookingType.NotBooked;
     }
     else
     {
         booked_ = true;
         type_ = bookingtype;
         bookedBy_ = bookedby;
         title_ = title;
         description_ = description;
     }
 }
예제 #37
0
    public static BookingType selectByBookingTypeId(int bookingTypeId, MySql connection)
    {
        string        selectBookingTypeId = "SELECT * FROM BookingType WHERE (bookingTypeId='" + bookingTypeId + "')";
        SqlDataReader bookingTypeIdFromDb = connection.Select(selectBookingTypeId);

        if (bookingTypeIdFromDb != null)
        {
            if (bookingTypeIdFromDb.HasRows)
            {
                bookingTypeIdFromDb.Read();
                BookingType returnBookingType = new BookingType(Convert.ToInt32(bookingTypeIdFromDb["bookingTypeId"]),
                                                                bookingTypeIdFromDb["description"].ToString());
                bookingTypeIdFromDb.Close();
                return(returnBookingType);
            }
            bookingTypeIdFromDb.Close();
            return(null);
        }
        return(null);
    }
예제 #38
0
        public bool delete(BookingType g)
        {
            string        sql  = "Delete Guest where GuestID = @id";
            SqlConnection conn = dp.getConnection();

            cmd = new SqlCommand(sql, conn);
            try
            {
                cmd = new SqlCommand(sql, conn);
                conn.Open();
                cmd.Parameters.Add("@id", SqlDbType.Char).Value = g.BookingTypeID;

                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
        public ActionResult BookingConfirm(BookingType bookingType, Guid specialistId, Guid specializationId, DateTime startTime, DateTime endTime)
        {
            UserDto specialist = Services.Users.GetUserById(specialistId);
            SpecializationDto specialization = Services.Users.GetSpecializationById(specializationId);

            if (specialist != null)
            {
                BookingConfirmViewModel model = new BookingConfirmViewModel()
                {
                    SubTitle = Enums.GetDescriptionEnum(PopUpSubTitle.Confirm),
                    Title = GetConfirmTitleByBookingType(bookingType),
                    Type = bookingType,
                    ConfirmMessage = GetBookingConfirmMessage(specialist, bookingType, specialization, startTime, endTime)
                };

                return PartialView("BookingPopUpTemplate/_BookingConfirm", model);
            }
            else
            {
                throw new Exception("SpecialistProfileController_BookingConfirm Error: Specialist is null");
            }
        }
예제 #40
0
 public decimal GetCustomerPrice(Guid specializationId, BookingType type)
 {
     Specialization specialization = Repository.FindById<Specialization>(specializationId);
     return GetCustomerPrice(specialization, type);
 }
예제 #41
0
        public decimal GetCustomerPrice(Specialization specialization, BookingType type)
        {
            decimal rate;

            try
            {
                switch (type)
                {
                    case BookingType.TalkNow:
                        rate = GetCustomerRate(specialization.TalkNowRate, specialization.GST);
                        break;

                    case BookingType.ASAP:
                        rate = GetCustomerRate(specialization.StandardRate, specialization.GST);
                        break;

                    case BookingType.StandardHour:
                        rate = GetCustomerRate(specialization.StandardRate, specialization.GST);
                        break;

                    case BookingType.OutOfHour:
                        rate = GetCustomerRate(specialization.OutOfHourRate, specialization.GST);
                        break;

                    default:
                        rate = 0;
                        break;
                }

                return rate;
            }
            catch (Exception e)
            {
                Log.Error(e.Message, e);
                throw new ArgumentException(e.Message);
            }
        }
예제 #42
0
        public decimal GetSpecialistPrice(Guid specializationId, BookingType type)
        {
            Specialization specialization = Repository.FindById<Specialization>(specializationId);
            decimal bookingRate = 0;
            switch (type)
            {
                case BookingType.ASAP:
                case BookingType.StandardHour:
                    bookingRate = specialization.StandardRate;
                    break;

                case BookingType.OutOfHour:
                    bookingRate = specialization.OutOfHourRate;
                    break;

                case BookingType.TalkNow:
                    bookingRate = specialization.TalkNowRate;
                    break;
            }
            return bookingRate;
        }
예제 #43
0
 /// <summary>
 /// get format datetime to display on popup
 /// </summary>
 /// <param name="type"></param>
 /// <param name="startTime"></param>
 /// <param name="endTime"></param>
 /// <returns></returns>
 public static string GetDisplayTime(BookingType type, BookingStatus status, DateTime? startTime, DateTime? endTime)
 {
     string result = string.Empty;
     if (BookingType.ASAP.Equals(type) && status == BookingStatus.Requested)
     {
         result = Constants.ASAPMessage;
     }
     else if (startTime.HasValue && endTime.HasValue)
     {
         if (startTime.Value.Date == DateTimeUtilities.GetDateTimeLocalNow().Date)
         {
             result = string.Format(Constants.TemplateDisplayTime, Constants.Today, startTime.Value.ToString(Constants.TimeFormat12hFull), endTime.Value.ToString(Constants.TimeFormat12hFull));
         }
         else
         {
             if (startTime.Value.Date == endTime.Value.Date)
             {
                 result = string.Format(Constants.TemplateDisplayTime, startTime.Value.ToString(Constants.GlobalDateFormat), startTime.Value.ToString(Constants.TimeFormat12hFull), endTime.Value.ToString(Constants.TimeFormat12hFull));
             }
             else
             {
                 result = string.Format(Constants.TemplateDisplayDateTime, startTime.Value.ToString(Constants.GlobalDateFormat), startTime.Value.ToString(Constants.TimeFormat12hFull), endTime.Value.ToString(Constants.GlobalDateFormat), endTime.Value.ToString(Constants.TimeFormat12hFull));
             }
         }
     }
     else if (!startTime.HasValue || !endTime.HasValue)
     {
         result = string.Format("{0} - {0}", Constants.DetermineContent);
         if (startTime.HasValue)
         {
             result = string.Format(Constants.TemplateDisplayTime, startTime.Value.ToString(Constants.GlobalDateFormat), startTime.Value.ToString(Constants.TimeFormat12hFull), Constants.DetermineContent);
         }
     }
     return result;
 }
예제 #44
0
        private List<IPaymentRule> findPaymentRulesForBookingType(List<IPaymentRule> paymentRulesForCustomer, BookingType bookingType)
        {
            List<IPaymentRule> paymentRulesForBookingType = new List<IPaymentRule>();
            foreach (IPaymentRule paymentRule in paymentRulesForCustomer)
            {
                if (paymentRule.BookingType == bookingType)
                {
                    paymentRulesForBookingType.Add(paymentRule);
                }
            }

            return paymentRulesForBookingType;
        }
예제 #45
0
        internal void AddPaymentRule(Customer customer, BookingType bookingType, decimal percentage, int daysOffset, 
            BaseDate baseDate, PaymentType paymentType)
        {
            PaymentRule paymentRule = new PaymentRule(this, customer, bookingType, percentage, daysOffset, baseDate,
                paymentType, dataAccessFacade);

            readPaymentRules();
        }
        /// <summary>
        /// Get template of the confirm booking time message
        /// </summary>
        /// <param name="specialistDto"></param>
        /// <returns></returns>
        protected string GetBookingConfirmMessage(UserDto specialistDto, BookingType type, SpecializationDto specializationDto, DateTime startTime, DateTime endTime)
        {
            decimal bookingRate = Services.Booking.GetCustomerPrice(specializationDto.Id, type);
            decimal minCharge = Services.Booking.GetCustomerMinimumPrice(specializationDto.Id);

            string confirmMessage = string.Empty;
            switch (type)
            {
                case BookingType.ASAP:
                    confirmMessage = BuildConfirmMessage("a consultation as soon as possible", specialistDto, bookingRate, minCharge, specializationDto.IsApplyNoMinimumCharge);
                    break;

                case BookingType.StandardHour:
                    confirmMessage = BuildConfirmMessage("a consultation between " + startTime.ToString(Constants.GlobalDateTimeFormat) +
                        " and " + endTime.ToString(Constants.GlobalDateTimeFormat), specialistDto, bookingRate, minCharge, specializationDto.IsApplyNoMinimumCharge);
                    break;

                case BookingType.OutOfHour:
                    confirmMessage = BuildConfirmMessage("a consultation between " + startTime.ToString(Constants.GlobalDateTimeFormat) +
                        " and " + endTime.ToString(Constants.GlobalDateTimeFormat), specialistDto, bookingRate, minCharge, specializationDto.IsApplyNoMinimumCharge);
                    break;

                case BookingType.TalkNow:
                    confirmMessage = BuildConfirmMessage("to talk now", specialistDto, bookingRate, minCharge, specializationDto.IsApplyNoMinimumCharge);
                    break;
            }

            return confirmMessage;
        }
        public ActionResult BookingRequest(BookingType bookingType)
        {
            BookingATimeRequestViewModel model = new BookingATimeRequestViewModel()
            {
                SubTitle = Enums.GetDescriptionEnum(PopUpSubTitle.Enquiry),
                Title = GetRequestTitleByBookingType(bookingType),
                Type = bookingType,
                StartTime = DateTimeUtilities.GetDateTimeLocalNow(),
                EndTime = DateTimeUtilities.GetDateTimeLocalNow()
            };

            // Get minimum lead time and minimum booking preference
            ViewBag.MINIMUM_LEAD_TIME = Services.SystemConfig.GetValueByKey(ParamatricBusinessRules.MINIMUM_LEAD_TIME.ToString());
            ViewBag.MINIMUM_BOOKING = Services.SystemConfig.GetValueByKey(ParamatricBusinessRules.MINIMUM_BOOKING.ToString());
            if (bookingType == BookingType.StandardHour || bookingType == BookingType.OutOfHour)
            {
                return PartialView("BookingPopUpTemplate/_BookTimeRequest", model);
            }
            else
            {
                return PartialView("BookingPopUpTemplate/_ASAPRequest", model);
            }
        }
        /// <summary>
        /// Get request title by booking type
        /// </summary>
        /// <param name="bookingType"></param>
        /// <returns></returns>
        public string GetRequestTitleByBookingType(BookingType type)
        {
            string bookingType = Enum.GetName(typeof(BookingType), type);
            var title = Enums.GetDescriptionEnum((RequestPopUpTitle)Enum.Parse(typeof(RequestPopUpTitle), bookingType));

            return title;
        }
        public ActionResult CreateBooking(Guid specialistId, string enquiry, DateTime startTime, DateTime endTime, BookingType bookingType, Guid specializationId)
        {
            UserDto specialistDto = Services.Users.GetUserById(specialistId);
            if (specialistDto != null)
            {
                UserDto customerDto = Services.Users.GetUserById(CurrentUser.Id);
                SpecializationDto specializationDto = Services.Users.GetSpecializationById(specializationId);
                if (bookingType.Equals(BookingType.ASAP))
                {
                    startTime = DateTimeUtilities.GetDateTimeLocalNow();
                    endTime = DateTimeUtilities.GetDateTimeLocalNow();
                }
                if (customerDto != null)
                {
                    BookingViewModel newBooking = new BookingViewModel()
                    {
                        Enquiry = enquiry,
                        StartTime = startTime,
                        EndTime = endTime,
                        Type = bookingType,
                        IsApplyNoMinimumCharge = specializationDto.IsApplyNoMinimumCharge,
                        CustomerMinCharge = Services.Booking.GetCustomerMinimumPrice(specializationDto.Id),
                        SpecialistMinCharge = specializationDto.MinimumCharge,
                        CostPerMinute = Services.Booking.GetCustomerPrice(specializationDto.Id, bookingType),
                        RatePerMinute = Services.Booking.GetSpecialistPrice(specializationDto.Id, bookingType),
                        Status = BookingStatus.Requested,
                    };

                    BookingDto newBookingDto = Mapper.Map<BookingDto>(newBooking);
                    newBookingDto.Specialist = specialistDto;
                    newBookingDto.Customer = customerDto;
                    newBookingDto.Specialization = specializationDto;

                    // Insert to database
                    newBookingDto = Services.Booking.Create(newBookingDto);

                    // Reload alert and booking list
                    NotifyHelper.ReloadAlert(newBookingDto.Specialist.UserName);
                    NotifyHelper.ReloadAlert(newBookingDto.Customer.UserName);

                    return Json(new { Success = true }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return Json(new { Success = false, ErrorMessage = "Customer does not exists" }, JsonRequestBehavior.AllowGet);
                }
            }
            else
            {
                return Json(new { Success = false, ErrorMessage = "Expert does not exists" }, JsonRequestBehavior.AllowGet);
            }
        }
예제 #50
0
        public IPaymentRule CreatePaymentRule(ISupplier supplierEntity, ICustomer customerEntity, 
            BookingType bookingType, decimal percentage, int daysOffset, BaseDate baseDate, PaymentType paymentType)
        {
            SupplierEntity s = (SupplierEntity)supplierEntity;
            CustomerEntity c = (CustomerEntity)customerEntity;

            return paymentRuleMapper.Create(s, c, bookingType, percentage, daysOffset, baseDate, paymentType);
        }