Beispiel #1
0
        public async Task <bool> DeleteActor(int id)
        {
            var actor = await _context.Users.FindAsync(id);

            if (actor == null)
            {
                return(false);
            }
            try
            {
                actor.UserIsDelete          = IsDelete.ISDELETED;
                _context.Entry(actor).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
        public async Task <bool> DeleteActorInScenario(int actorInScenarioID)
        {
            var actorInScenario = await _context.ActorRoles.FindAsync(actorInScenarioID);

            if (actorInScenario == null)
            {
                return(false);
            }
            try
            {
                actorInScenario.IsDelete = IsDelete.ISDELETED;
                _context.Entry(actorInScenario).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
        public async Task <bool> DeleteScenario(int id)
        {
            var scenario = await _context.Scenarios.FindAsync(id);

            if (scenario == null)
            {
                return(false);
            }
            try
            {
                scenario.ScenarioIsDelete      = IsDelete.ISDELETED;
                _context.Entry(scenario).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
        public async Task <bool> DeleteEquipment(int id)
        {
            var equipment = await _context.Equipments.FindAsync(id);

            if (equipment == null)
            {
                return(false);
            }
            try
            {
                equipment.EquipmentIsDelete     = IsDelete.ISDELETED;
                _context.Entry(equipment).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
        public async Task <bool> SubEquipmentInScenario(int id, int quantity)
        {
            Equipment equipmentModel = await _context.Equipments.FindAsync(id);

            if (equipmentModel == null)
            {
                return(false);
            }
            equipmentModel.EquipmentQuantity     = equipmentModel.EquipmentQuantity - quantity;
            _context.Entry(equipmentModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }