コード例 #1
0
ファイル: Course.cs プロジェクト: jmeroy03/scheduler
 public Course(
     Int64 id, 
     String name, 
     String description, 
     Double units, 
     Boolean isLaboratory, 
     Boolean isServiceCourse,
     AvailabilityEnum availability)
 {
     this.id = id;
     this.name = name;
     this.description = description;
     this.units = units;
     this.isLaboratory = isLaboratory;
     this.isServiceCourse = isServiceCourse;
     this.availability = availability;
     SubItems[0].Text = name.ToString();
     SubItems.Add(description.ToString());
     SubItems.Add(units.ToString());
     SubItems.Add(isLaboratory ? "Yes" : "No");
     SubItems.Add(isServiceCourse ? "Yes" : "No");
     SubItems.Add(availability == AvailabilityEnum.EverySemester ? "Every Semester" :
                 availability == AvailabilityEnum.FirstSemesterOnly ? "1st Semester Only" :
                     "2nd Semester Only");
 }
コード例 #2
0
        public async Task <bool> ChangeCategoryAvailability(int id, AvailabilityEnum newAvailability)
        {
            var category = await _unitOfWork.CategoryRepository.GetById(id);

            if (category.Availability == AvailabilityEnum.Private)
            {
                return(false);                                                    //admin can't publish someone's private category
            }
            category.Availability = newAvailability;
            _unitOfWork.CategoryRepository.Update(category);
            await _unitOfWork.SaveChangesAsync();

            return(true);
        }
コード例 #3
0
        public void SetActionAvailability(ActionEnum ac, AvailabilityEnum av)
        {
            ActionAvailability aa;

            if (_ActionAvailability.TryGetValue(ac, out aa))
            {
                aa.Availability = av;
            }
            else
            {
                aa = new ActionAvailability(ac, av);
                _ActionAvailability.Add(ac, aa); // Note we are adding the ActionAvailability object as the value
                ActionAvailabilityList.Add(aa);  // Also add it to the list that is in included in the JSON export
            }
        }
コード例 #4
0
        /// <see cref="ICommandExecutor.GetCommandAvailability"/>
        public AvailabilityEnum GetCommandAvailability(Scenario scenario, string commandType, string commandParameter, IEnumerable <int> entityIDs)
        {
            /// Get all the existing entities from the scenario that are currently attached to the map.
            RCSet <Entity> entitySet = this.GetEntitiesOnMap(scenario, entityIDs);

            if (entitySet.Count == 0)
            {
                return(AvailabilityEnum.Unavailable);
            }

            /// Select the factories to be used and get the availability of the command from the selected factories
            /// and combine the results.
            bool isAnyUnavailable = true;
            bool isAnyDisabled    = false;

            foreach (ICommandExecutionFactory factory in this.SelectFactories(commandType, entitySet))
            {
                isAnyUnavailable = false;
                AvailabilityEnum availability = factory.GetCommandAvailability(entitySet, commandParameter);
                if (availability == AvailabilityEnum.Unavailable)
                {
                    /// If any of the factories says that the command execution is unavailable then the overall result is unavailable.
                    isAnyUnavailable = true;
                    break;
                }
                else if (availability == AvailabilityEnum.Disabled)
                {
                    /// If every factories says that the command execution is available but any of them says that its
                    /// currently disabled, then the overall result is disabled.
                    isAnyDisabled = true;
                }
            }

            /// Return the result based on the collected flags.
            if (isAnyUnavailable)
            {
                return(AvailabilityEnum.Unavailable);
            }
            if (isAnyDisabled)
            {
                return(AvailabilityEnum.Disabled);
            }
            return(AvailabilityEnum.Enabled);
        }
コード例 #5
0
        /// <summary>
        /// Tries to attach the given command input listener to the appropriate command button slot if the given listener is a command button
        /// listener, and the state of the given listener is not CommandButtonStateEnum.Invisible.
        /// </summary>
        /// <param name="listener">The command input listener to attach.</param>
        /// <remarks>
        /// If the given command input listener is not a command button listener, or its state is CommandButtonStateEnum.Invisible then this
        /// function has no effect.
        /// </remarks>
        private void TryAttachAsButtonListener(CommandInputListener listener)
        {
            IButtonListener buttonListener = listener as IButtonListener;

            if (buttonListener == null)
            {
                return;
            }

            AvailabilityEnum buttonAvailability = buttonListener.ButtonAvailability;

            if (buttonAvailability == AvailabilityEnum.Unavailable)
            {
                return;
            }

            RCIntVector slotPosition = buttonListener.CommandPanelSlot;

            if (this.commandPanelSlots[slotPosition.X, slotPosition.Y] != null)
            {
                if (this.commandPanelSlots[slotPosition.X, slotPosition.Y].ButtonListener.Priority > buttonListener.Priority)
                {
                    /// Another IButtonListener with higher priority has already been attached to the command panel slot.
                    return;
                }
                else if (this.commandPanelSlots[slotPosition.X, slotPosition.Y].ButtonListener.Priority == buttonListener.Priority)
                {
                    throw new InvalidOperationException(string.Format("Another IButtonListener with the same priority has already been attached to command panel slot {0}!", slotPosition));
                }
            }

            this.commandPanelSlots[slotPosition.X, slotPosition.Y] = new CommandPanelSlot
            {
                ButtonState    = buttonAvailability == AvailabilityEnum.Disabled ? CommandButtonStateEnum.Disabled : CommandButtonStateEnum.Enabled,
                ButtonSprite   = buttonListener.ButtonSprite,
                ButtonListener = buttonListener,
                Listener       = listener
            };
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GetCorporationsCorporationIdContracts200Ok" /> class.
 /// </summary>
 /// <param name="AcceptorId">Who will accept the contract (required).</param>
 /// <param name="AssigneeId">ID to whom the contract is assigned, can be corporation or character ID (required).</param>
 /// <param name="Availability">To whom the contract is available (required).</param>
 /// <param name="Buyout">Buyout price (for Auctions only).</param>
 /// <param name="Collateral">Collateral price (for Couriers only).</param>
 /// <param name="ContractId">contract_id integer (required).</param>
 /// <param name="DateAccepted">Date of confirmation of contract.</param>
 /// <param name="DateCompleted">Date of completed of contract.</param>
 /// <param name="DateExpired">Expiration date of the contract (required).</param>
 /// <param name="DateIssued">Сreation date of the contract (required).</param>
 /// <param name="DaysToComplete">Number of days to perform the contract.</param>
 /// <param name="EndLocationId">End location ID (for Couriers contract).</param>
 /// <param name="ForCorporation">true if the contract was issued on behalf of the issuer&#39;s corporation (required).</param>
 /// <param name="IssuerCorporationId">Character&#39;s corporation ID for the issuer (required).</param>
 /// <param name="IssuerId">Character ID for the issuer (required).</param>
 /// <param name="Price">Price of contract (for ItemsExchange and Auctions).</param>
 /// <param name="Reward">Remuneration for contract (for Couriers only).</param>
 /// <param name="StartLocationId">Start location ID (for Couriers contract).</param>
 /// <param name="Status">Status of the the contract (required).</param>
 /// <param name="Title">Title of the contract.</param>
 /// <param name="Type">Type of the contract (required).</param>
 /// <param name="Volume">Volume of items in the contract.</param>
 public GetCorporationsCorporationIdContracts200Ok(int?AcceptorId = default(int?), int?AssigneeId = default(int?), AvailabilityEnum Availability = default(AvailabilityEnum), double?Buyout = default(double?), double?Collateral = default(double?), int?ContractId = default(int?), DateTime?DateAccepted = default(DateTime?), DateTime?DateCompleted = default(DateTime?), DateTime?DateExpired = default(DateTime?), DateTime?DateIssued = default(DateTime?), int?DaysToComplete = default(int?), long?EndLocationId = default(long?), bool?ForCorporation = default(bool?), int?IssuerCorporationId = default(int?), int?IssuerId = default(int?), double?Price = default(double?), double?Reward = default(double?), long?StartLocationId = default(long?), StatusEnum Status = default(StatusEnum), string Title = default(string), TypeEnum Type = default(TypeEnum), double?Volume = default(double?))
 {
     // to ensure "AcceptorId" is required (not null)
     if (AcceptorId == null)
     {
         throw new InvalidDataException("AcceptorId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.AcceptorId = AcceptorId;
     }
     // to ensure "AssigneeId" is required (not null)
     if (AssigneeId == null)
     {
         throw new InvalidDataException("AssigneeId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.AssigneeId = AssigneeId;
     }
     // to ensure "Availability" is required (not null)
     if (Availability == null)
     {
         throw new InvalidDataException("Availability is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.Availability = Availability;
     }
     // to ensure "ContractId" is required (not null)
     if (ContractId == null)
     {
         throw new InvalidDataException("ContractId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.ContractId = ContractId;
     }
     // to ensure "DateExpired" is required (not null)
     if (DateExpired == null)
     {
         throw new InvalidDataException("DateExpired is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.DateExpired = DateExpired;
     }
     // to ensure "DateIssued" is required (not null)
     if (DateIssued == null)
     {
         throw new InvalidDataException("DateIssued is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.DateIssued = DateIssued;
     }
     // to ensure "ForCorporation" is required (not null)
     if (ForCorporation == null)
     {
         throw new InvalidDataException("ForCorporation is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.ForCorporation = ForCorporation;
     }
     // to ensure "IssuerCorporationId" is required (not null)
     if (IssuerCorporationId == null)
     {
         throw new InvalidDataException("IssuerCorporationId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.IssuerCorporationId = IssuerCorporationId;
     }
     // to ensure "IssuerId" is required (not null)
     if (IssuerId == null)
     {
         throw new InvalidDataException("IssuerId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.IssuerId = IssuerId;
     }
     // to ensure "Status" is required (not null)
     if (Status == null)
     {
         throw new InvalidDataException("Status is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.Status = Status;
     }
     // to ensure "Type" is required (not null)
     if (Type == null)
     {
         throw new InvalidDataException("Type is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.Type = Type;
     }
     this.Buyout          = Buyout;
     this.Collateral      = Collateral;
     this.DateAccepted    = DateAccepted;
     this.DateCompleted   = DateCompleted;
     this.DaysToComplete  = DaysToComplete;
     this.EndLocationId   = EndLocationId;
     this.Price           = Price;
     this.Reward          = Reward;
     this.StartLocationId = StartLocationId;
     this.Title           = Title;
     this.Volume          = Volume;
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GetCorporationsCorporationIdContracts200Ok" /> class.
 /// </summary>
 /// <param name="contractId">contract_id integer (required).</param>
 /// <param name="issuerId">Character ID for the issuer (required).</param>
 /// <param name="issuerCorporationId">Character&#39;s corporation ID for the issuer (required).</param>
 /// <param name="assigneeId">ID to whom the contract is assigned, can be corporation or character ID (required).</param>
 /// <param name="acceptorId">Who will accept the contract (required).</param>
 /// <param name="startLocationId">Start location ID (for Couriers contract).</param>
 /// <param name="endLocationId">End location ID (for Couriers contract).</param>
 /// <param name="type">Type of the contract (required).</param>
 /// <param name="status">Status of the the contract (required).</param>
 /// <param name="title">Title of the contract.</param>
 /// <param name="forCorporation">true if the contract was issued on behalf of the issuer&#39;s corporation (required).</param>
 /// <param name="availability">To whom the contract is available (required).</param>
 /// <param name="dateIssued">Сreation date of the contract (required).</param>
 /// <param name="dateExpired">Expiration date of the contract (required).</param>
 /// <param name="dateAccepted">Date of confirmation of contract.</param>
 /// <param name="daysToComplete">Number of days to perform the contract.</param>
 /// <param name="dateCompleted">Date of completed of contract.</param>
 /// <param name="price">Price of contract (for ItemsExchange and Auctions).</param>
 /// <param name="reward">Remuneration for contract (for Couriers only).</param>
 /// <param name="collateral">Collateral price (for Couriers only).</param>
 /// <param name="buyout">Buyout price (for Auctions only).</param>
 /// <param name="volume">Volume of items in the contract.</param>
 public GetCorporationsCorporationIdContracts200Ok(int?contractId = default(int?), int?issuerId = default(int?), int?issuerCorporationId = default(int?), int?assigneeId = default(int?), int?acceptorId = default(int?), long?startLocationId = default(long?), long?endLocationId = default(long?), TypeEnum type = default(TypeEnum), StatusEnum status = default(StatusEnum), string title = default(string), bool?forCorporation = default(bool?), AvailabilityEnum availability = default(AvailabilityEnum), DateTime?dateIssued = default(DateTime?), DateTime?dateExpired = default(DateTime?), DateTime?dateAccepted = default(DateTime?), int?daysToComplete = default(int?), DateTime?dateCompleted = default(DateTime?), double?price = default(double?), double?reward = default(double?), double?collateral = default(double?), double?buyout = default(double?), double?volume = default(double?))
 {
     // to ensure "contractId" is required (not null)
     if (contractId == null)
     {
         throw new InvalidDataException("contractId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.ContractId = contractId;
     }
     // to ensure "issuerId" is required (not null)
     if (issuerId == null)
     {
         throw new InvalidDataException("issuerId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.IssuerId = issuerId;
     }
     // to ensure "issuerCorporationId" is required (not null)
     if (issuerCorporationId == null)
     {
         throw new InvalidDataException("issuerCorporationId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.IssuerCorporationId = issuerCorporationId;
     }
     // to ensure "assigneeId" is required (not null)
     if (assigneeId == null)
     {
         throw new InvalidDataException("assigneeId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.AssigneeId = assigneeId;
     }
     // to ensure "acceptorId" is required (not null)
     if (acceptorId == null)
     {
         throw new InvalidDataException("acceptorId is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.AcceptorId = acceptorId;
     }
     // to ensure "type" is required (not null)
     if (type == null)
     {
         throw new InvalidDataException("type is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.Type = type;
     }
     // to ensure "status" is required (not null)
     if (status == null)
     {
         throw new InvalidDataException("status is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.Status = status;
     }
     // to ensure "forCorporation" is required (not null)
     if (forCorporation == null)
     {
         throw new InvalidDataException("forCorporation is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.ForCorporation = forCorporation;
     }
     // to ensure "availability" is required (not null)
     if (availability == null)
     {
         throw new InvalidDataException("availability is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.Availability = availability;
     }
     // to ensure "dateIssued" is required (not null)
     if (dateIssued == null)
     {
         throw new InvalidDataException("dateIssued is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.DateIssued = dateIssued;
     }
     // to ensure "dateExpired" is required (not null)
     if (dateExpired == null)
     {
         throw new InvalidDataException("dateExpired is a required property for GetCorporationsCorporationIdContracts200Ok and cannot be null");
     }
     else
     {
         this.DateExpired = dateExpired;
     }
     this.StartLocationId = startLocationId;
     this.EndLocationId   = endLocationId;
     this.Title           = title;
     this.DateAccepted    = dateAccepted;
     this.DaysToComplete  = daysToComplete;
     this.DateCompleted   = dateCompleted;
     this.Price           = price;
     this.Reward          = reward;
     this.Collateral      = collateral;
     this.Buyout          = buyout;
     this.Volume          = volume;
 }
コード例 #8
0
 public ActionAvailability(ActionEnum ac, AvailabilityEnum av)
 {
     Action       = ac;
     Availability = av;
 }
コード例 #9
0
ファイル: Course.cs プロジェクト: jmeroy03/scheduler
 public static Course Add(
     String name,
     String description,
     Double units,
     Boolean isLaboratory,
     Boolean isServiceCourse,
     AvailabilityEnum availability)
 {
     Int64 id;
     using (MySqlConnection con = new MySqlConnection(Program.CONNECTION_STRING))
     {
         MySqlCommand com = new MySqlCommand(
             @"INSERT INTO COURSE(COURSE_NAME, DESCRIPTION, UNITS, LABORATORY, CLASSIFICATION, AVAILABILITY) " +
             "VALUES(@courseName, @description, @units, @laboratory, @classification, @availability)", con);
         com.Parameters.AddWithValue("@courseName", name);
         com.Parameters.AddWithValue("@description", description);
         com.Parameters.AddWithValue("@units", units);
         com.Parameters.AddWithValue("@laboratory", isLaboratory ? 'T' : 'F');
         com.Parameters.AddWithValue("@classification", isServiceCourse ? 'T' : 'F');
         com.Parameters.AddWithValue("@availability",
             availability == AvailabilityEnum.EverySemester ? 'E' :
                 availability == AvailabilityEnum.FirstSemesterOnly ? '1' :
                     '2');
         con.Open();
         com.ExecuteNonQuery();
         id = com.LastInsertedId;
         con.Close();
         com.Dispose();
     }
     Course course = new Course(id, name, description, units, isLaboratory, isServiceCourse, availability);
     return course;
 }