Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateCategoryAsync(CalendarEventCategory category,
                                                              [FromServices] IMongoCollection <CalendarEventCategory> mongoCollection)
        {
            if (category == null || !category.AreValuesCorrect())
            {
                return(this.Error(HttpStatusCode.UnprocessableEntity,
                                  "CalendarEventCategory is null or it's properties are empty!"));
            }
            CalendarEventCategory currentValue = await mongoCollection.FirstOrDefaultAsync(x => x.ID == category.ID);

            if (currentValue == null)
            {
                return(this.Error(HttpStatusCode.UnprocessableEntity,
                                  "Sended CalendarEventCategory to update has altered Id! Unable to update value!"));
            }
            UpdateResult result = await mongoCollection.UpdateOneAsync(x => x.ID == category.ID,
                                                                       Extensions.GenerateUpdateDefinition <CalendarEventCategory>(currentValue, category));

            if (result.IsAcknowledged)
            {
                return(this.Success(""));
            }
            else
            {
                return(this.Error(HttpStatusCode.InternalServerError, "Value wasn't updated!"));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddCategoryAsync(CalendarEventCategory category,
                                                           [FromServices] IMongoCollection <CalendarEventCategory> mongoCollection)
        {
            if (category == null || !category.AreValuesCorrect())
            {
                return(this.Error(HttpStatusCode.UnprocessableEntity,
                                  "CalendarEventCategory is null or it's properties are empty!"));
            }
            category.ID = Guid.NewGuid();
            await mongoCollection.InsertOneAsync(category);

            return(this.Success(category.ID));
        }
Ejemplo n.º 3
0
 public CalendarEvent_v1(CalendarEvent v0)
 {
     this.triggerDate    = v0.triggerDate;
     this.uiState        = v0.uiState;
     this.triggerState   = v0.triggerState;
     this.OnButtonClick  = v0.OnButtonClick;
     this.OnEventTrigger = v0.OnEventTrigger;
     this.message        = v0.message;
     this.effect         = v0.effect;
     this.displayEffect  = v0.displayEffect;
     this.category       = v0.category;
     this.mCachedDynamicDescriptionTextID = v0.description;
     this.mustRespond       = v0.mustRespond;
     this.interruptGameTime = v0.interruptGameTime;
     this.showOnCalendar    = v0.showOnCalendar;
 }
Ejemplo n.º 4
0
 public CalendarEvent_v1()
 {
     this.triggerDate       = new DateTime();
     this.uiState           = CalendarEvent.UIState.None;
     this.triggerState      = GameState.Type.None;
     this.OnButtonClick     = (MMAction)null;
     this.OnEventTrigger    = (MMAction)null;
     this.message           = (Message)null;
     this.effect            = (EventEffect)null;
     this.displayEffect     = (DisplayEffect)null;
     this.category          = CalendarEventCategory.Unknown;
     this.mustRespond       = false;
     this.interruptGameTime = false;
     this.showOnCalendar    = false;
     this.mCachedDynamicDescriptionTextID = (string)null;
 }