public async Task <IActionResult> PutSceneActor([FromRoute] int id, [FromBody] SceneActor sceneActor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sceneActor.SceneId)
            {
                return(BadRequest());
            }

            _context.Entry(sceneActor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SceneActorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutAccount([FromRoute] string id, [FromBody] Account account)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != account.AccountId)
            {
                return(BadRequest());
            }

            _context.Entry(account).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task AddActor(ActorInfoVM actor)
        {
            TblAccount accountModel = new TblAccount();

            accountModel.AccName        = actor.AccName;
            accountModel.AccPassword    = actor.AccPassword;
            accountModel.AccImage       = actor.AccImage;
            accountModel.AccPhoneNum    = actor.AccPhoneNum;
            accountModel.AccEmail       = actor.AccEmail;
            accountModel.AccDescription = actor.AccDescription;
            accountModel.AccAdress      = actor.AccAdress;
            accountModel.AccRole        = Role.USER;
            accountModel.AccStatus      = Status.AVAILABLE;
            accountModel.AccIsDelete    = IsDelete.ACTIVE;
            accountModel.AccCreateBy    = actor.AccCreateBy;
            accountModel.AccUpdateTime  = actor.AccUpdateTime;
            accountModel.AccUpdateBy    = actor.AccUpdateBy;;


            _context.TblAccounts.Add(accountModel);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
Esempio n. 4
0
        public async Task AddScenario(ScenarioInfoVM scenario)
        {
            TblScenario scenarioModel = new TblScenario();

            scenarioModel.ScenarioName      = scenario.ScenarioName;
            scenarioModel.ScenarioDes       = scenario.ScenarioDes;
            scenarioModel.ScenarioImage     = scenario.ScenarioImage;
            scenarioModel.ScenarioCastAmout = scenario.ScenarioCastAmout;
            scenarioModel.ScenarioLocation  = scenario.ScenarioLocation;
            scenarioModel.ScenarioTimeFrom  = scenario.ScenarioTimeFrom;
            scenarioModel.ScenarioTimeTo    = scenario.ScenarioTimeTo;
            scenarioModel.ScenarioStatus    = Status.AVAILABLE;
            scenarioModel.ScenarioIsDelete  = IsDelete.ACTIVE;
            scenarioModel.ScenarioScript    = scenario.ScenarioScript;

            _context.TblScenarios.Add(scenarioModel);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
        public async Task AddEquipment(EquipmentInfoVM equipment)
        {
            TblEquipment equipmentModel = new TblEquipment();

            equipmentModel.EquipmentName     = equipment.EquipmentName;
            equipmentModel.EquipmentImage    = equipment.EquipmentImage;
            equipmentModel.EquipmentDes      = equipment.EquipmentDes;
            equipmentModel.EquipmentQuantity = equipment.EquipmentQuantity;
            equipmentModel.EquipmentStatus   = Status.AVAILABLE;
            equipmentModel.EquipmentIsDelete = IsDelete.ACTIVE;
            // change here
            _context.TblEquipments.Add(equipmentModel);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> PutTblScene(int id, TblScene tblScene)
        {
            if (id != tblScene.Id)
            {
                return(BadRequest());
            }

            var t = _context.TblScene.Where(scene => scene.Id == id).FirstOrDefault();

            if (t != null)
            {
                t.Name = tblScene.Name;
                t.NumberOfShotScenes = tblScene.NumberOfShotScenes;
                t.StartDay           = tblScene.StartDay;
                t.EndDay             = tblScene.EndDay;
                t.Director           = tblScene.Director;
                t.FileDocOfRole      = tblScene.FileDocOfRole;
                t.Description        = tblScene.Description;
                t.Lastmodified       = DateTime.Now;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblSceneExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
Esempio n. 7
0
        public async Task <IActionResult> PutAccount(string id, string oldPassword, TblAccount account)
        {
            if (id != account.Username)
            {
                return(BadRequest());
            }

            var acc = _context.TblAccount.Where(ac => ac.Username == id).FirstOrDefault();

            if (acc != null)
            {
                if (oldPassword == acc.Password)
                {
                    acc.Password = account.Password;
                }
                else
                {
                    return(BadRequest("Wrong old password"));
                }
            }
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
Esempio n. 8
0
        public async Task <IActionResult> PutTblActor(string id, TblActor tblActor)
        {
            if (id != tblActor.Username)
            {
                return(BadRequest());
            }

            var t = _context.TblActor.Where(actor => actor.Username == id).FirstOrDefault();

            if (t != null)
            {
                t.Name         = tblActor.Name;
                t.Phone        = tblActor.Phone;
                t.Img          = tblActor.Img;
                t.Email        = tblActor.Email;
                t.Description  = tblActor.Description;
                t.Lastmodified = DateTime.Now;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblActorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
Esempio n. 9
0
        public async Task <IActionResult> PutTblTool(int id, TblTool tblTool)
        {
            if (id != tblTool.Id)
            {
                return(BadRequest());
            }

            var t = _context.TblTool.Where(tool => tool.Id == id).FirstOrDefault();

            if (t != null)
            {
                t.Name         = tblTool.Name;
                t.Amount       = tblTool.Amount;
                t.Description  = tblTool.Description;
                t.Img          = tblTool.Img;
                t.Status       = true;
                t.Username     = tblTool.Username;
                t.LastModified = DateTime.Now;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblToolExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(Ok(true));
        }