Example #1
0
        public ActionResult Save(ReservationDate reservation)
        {
            var _contactID = (int)TempData["ContactID"];

            var _locationName = Request["locationName"];

            var _contact = _context.Contacts
                           .Single(r => r.Id == _contactID);

            var _location = _context.Reservations
                            .Single(r => r.Name == _locationName);

            var _ReservedDate = (DateTime)TempData["BookDate"];

            var _InfoFromTextBox = (string)TempData["InfoFromTextBox"];

            var __reservation = new ReservationDate
            {
                ReservedDate    = _ReservedDate,
                Contact         = _contact,
                Reservation     = _location,
                InfoFromTextBox = _InfoFromTextBox,
                Deleted         = false
            };

            _context.ReservationDates.Add(__reservation);

            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #2
0
        /// <summary>
        /// 予約受付日が申込期間の範囲に収まっているかどうかを判定します。
        /// </summary>
        /// <param name="reservationDate">予約受付日。</param>
        public void EnsureValidReservationDate(ReservationDate reservationDate)
        {
            if (this.StartDate <= reservationDate.Value || reservationDate.Value <= this.EndDate)
            {
                return;
            }

            throw new ArgumentException("申込期間の範囲外の予約受付日が指定されています。");
        }
 public Reservation(ReaderId readerId, CopyId copyId)
 {
     ReservationId   = new ReservationId(Guid.NewGuid());
     ReaderId        = readerId;
     CopyId          = copyId;
     ReservationDate = DateTime.Now;
     ReleaseDate     = ReservationDate.AddDays(1);
     Status          = ReservationStatus.Pending;
 }
Example #4
0
 // Override function
 public override string ToString()
 {
     return(string.Format("{0} from agency no. {1} has created the reservation no. {2} in {3}. Arrival date: {4}. {5} for {6}. Price: {7} NIS.",
                          ContactPerson,
                          AgencyID,
                          ReservationID,
                          ReservationDate.ToString(CalendarType),
                          ArrivalDate.ToString(CalendarType),
                          Beds == 1 ? "One bed" : Beds + " beds",
                          Days == 1 ? "one day" : Days + " days",
                          Price));
 }
Example #5
0
        public ActionResult Delete(ReservationDate reservation)
        {
            var _reservation = _context.ReservationDates
                               .Include(r => r.Reservation)
                               .Include(r => r.Contact)
                               .SingleOrDefault(r => r.Id == reservation.Id);

            _reservation.Deleted = true;

            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #6
0
        public ActionResult ConfirmLocation(ReservationDate date)
        {
            TempData["BookDate"] = date.ReservedDate;

            TempData["InfoFromTextBox"] = date.InfoFromTextBox;

            var locations = _context.ReservationDates
                            .Include(r => r.Reservation)
                            .Include(r => r.Contact)
                            .ToList();

            return(View(locations));
        }
        public async Task AddReservationDate(DateTime startReservation, DateTime endReservartion, int roomNumber, int userId)
        {
            var getRoom      = _rac.Rooms.FirstOrDefault(x => x.Number == roomNumber);
            var reservartion = new ReservationDate()
            {
                StartReservarion = startReservation,
                EndReservation   = endReservartion,
                RoomId           = getRoom.Id,
                UserId           = userId
            };
            await _rac.ReservationDate.AddAsync(reservartion);

            await _rac.SaveChangesAsync();
        }
Example #8
0
        /// <summary>
        /// gives amount of customers, reservations and parkingspots in this class
        /// </summary>
        /// <returns>string with amount of customers, reservations and parkingspots</returns>
        public override string ToString()
        {
            string ID              = "ID: " + this.ID.ToString();
            string customerName    = "Customername: " + Customer.Name;
            string parkingspotName = "Parkingspot: " + ParkingSpot.Spotname;
            string reservationDate = "Reservation Date: " + ReservationDate.ToString();

            string spotInfo = ID + ", " +
                              customerName + ", " +
                              parkingspotName + ", " +
                              reservationDate;

            return(spotInfo);
        }
Example #9
0
        public ActionResult Update(ReservationDate reservation)
        {
            var _reservation = _context.ReservationDates
                               .Include(r => r.Reservation)
                               .Include(r => r.Contact)
                               .SingleOrDefault(r => r.Id == reservation.Id);

            _reservation.ReservedDate = reservation.ReservedDate;

            _reservation.InfoFromTextBox = reservation.InfoFromTextBox;

            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #10
0
        public bool IsFeasible(ReservationDate requestedDate,
                               int quantity)
        {
            var min           = requestedDate.Value.Date;
            var max           = requestedDate.Value.Date.AddDays(1);
            var reservedSeats = reservationsRepository.GetTotalReservations(min, max);

            var capacity = reservationsRepository.GetCapacity();

            if (quantity + reservedSeats > capacity)
            {
                return(false);
            }

            return(true);
        }
Example #11
0
        public ActionResult NewReservation(ReservationDate user)
        {
            var _existingContacts = _context.Contacts.ToList();

            foreach (var contact in _existingContacts)
            {
                if (contact.Id == ViewBag.ContactID)
                {
                    return(View(contact));
                }
            }
            _context.ReservationDates.Add(user);

            _context.SaveChanges();

            return(View(user));
        }
Example #12
0
        public ActionResult UpdateOrAddContact(ReservationDate user)
        {
            var _user = _context.Contacts.ToList();

            TempData["ContactNumber"] = user.Contact.ContactNumber;

            foreach (var contact in _user)
            {
                if (contact.ContactNumber == user.Contact.ContactNumber)
                {
                    return(RedirectToAction("NewReservation", "ReservationDates"));
                }
            }
            _context.Contacts.Add(user.Contact);

            _context.SaveChanges();

            return(RedirectToAction("NewReservation", "ReservationDates"));
        }
Example #13
0
 public override string ToString()
 {
     //return base.ToString();
     return(string.Format("Reservation nr. {0} created for {1}, containing {2}. \n Creationdate: {3}.", ID.ToString(), Customer.Fullname, Book.Title, ReservationDate.ToShortDateString()));
 }
        protected override void Execute(CodeActivityContext executionContext)
        {
            #region Declaration

            IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>();


            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve context.");
            }

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        Service        = serviceFactory.CreateOrganizationService(context.UserId);
            #endregion

            try
            {
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    Entity SalesEntity = (Entity)context.InputParameters["Target"];

                    //Logger.LogDebug("1", "get Target", Service);

                    if (SalesEntity.LogicalName == "new_contracting")
                    {
                        // Retrive Old Reservation Extension
                        QueryExpression qe = new QueryExpression();
                        qe.EntityName = "ohd_reservationextension";
                        qe.Criteria.Conditions.Add(new ConditionExpression("ohd_sale", ConditionOperator.Equal, SalesEntity.Id));
                        qe.ColumnSet = new ColumnSet();
                        qe.ColumnSet.Columns.Add("ohd_extensionenddate");
                        qe.AddOrder("ohd_extensionenddate", OrderType.Descending);
                        EntityCollection OldResExtension = Service.RetrieveMultiple(qe);

                        // Create Reservation Extension Entity
                        Entity ResExtension = new Entity("ohd_reservationextension");

                        ResExtension["ohd_sale"] = new EntityReference("new_contracting", SalesEntity.Id);

                        EntityReference SaleOwner = SaleOwnerReference.Get <EntityReference>(executionContext);
                        ResExtension["ohd_saleowner"] = SaleOwner;

                        ResExtension["ohd_daysnumber"] = DaysofExtension.Get <int>(executionContext);


                        if (OldResExtension.Entities.Count > 0)
                        {
                            DateTime LastExtension = (DateTime)OldResExtension[0].Attributes["ohd_extensionenddate"];
                            ResExtension["ohd_extensionenddate"] = LastExtension.AddDays(DaysofExtension.Get <int>(executionContext));
                        }
                        else
                        {
                            DateTime ReservationDate;
                            if (ReservationDateIn.Get(executionContext) != null)
                            {
                                ReservationDate = ReservationDateIn.Get <DateTime>(executionContext);
                            }
                            else
                            {
                                ReservationDate = DateTime.Now;
                            }

                            DateTime endDate = ReservationDate.AddDays(DaysofExtension.Get <int>(executionContext));
                            ResExtension["ohd_extensionenddate"] = endDate;
                        }

                        Guid id = Service.Create(ResExtension);
                        if (id != Guid.Empty)
                        {
                            Entity        relatedSale   = Service.Retrieve(SalesEntity.LogicalName, SalesEntity.Id, new ColumnSet("ownerid"));
                            AssignRequest assignRequest = new AssignRequest();
                            assignRequest.Assignee = new EntityReference("systemuser", ((EntityReference)relatedSale.Attributes["ownerid"]).Id);
                            assignRequest.Target   = new EntityReference(context.PrimaryEntityName, context.PrimaryEntityId);

                            Service.Execute(assignRequest);
                        }
                    }
                }
            }
            catch (Exception ex) {
                throw ex;
            }
        }