//[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
        public async Task <ActionResult> PutQ(int id, int a = 0)
        {
            var ProdD = myDBContext.Products.FirstOrDefault(x => x.ProductId == id);

            ProdD.Sku = ProdD.Sku + 1;
            myDBContext.Update(ProdD);
            await myDBContext.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("StudentID,Address,City,Country")] StudentAddress studentAddress)
        {
            if (id != studentAddress.StudentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studentAddress);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentAddressExists(studentAddress.StudentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudentID"] = new SelectList(_context.Student, "StudentID", "StudentID", studentAddress.StudentID);
            return(View(studentAddress));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Email,Phone,NoiDung")] Contact contact)
        {
            if (id != contact.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactExists(contact.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Hinh,MaHH")] QuangCao quangCao)
        {
            if (id != quangCao.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(quangCao);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuangCaoExists(quangCao.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(quangCao));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DepartmentID,DepartmentName")] Department department)
        {
            if (id != department.DepartmentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.DepartmentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
        public async Task <IActionResult> Edit(int ID, [Bind("MaLHP,NamHoc,HocKy,DiemGK,DiemCK,MaSV,Mon")] LopHocPhan lopHocPhan)
        {
            if (ID != lopHocPhan.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lopHocPhan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LopHocPhanExists(lopHocPhan.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaSV"]  = new SelectList(_context.SinhViens, "MaSV", "HoTen");
            ViewData["MaMon"] = new SelectList(_context.MonHocs, "MaMon", "TenMon");
            return(View(lopHocPhan));
        }
        public async Task <IActionResult> Edit(int id, [Bind("TransmissionId,Trasmission")] Transmissions transmissions)
        {
            if (id != transmissions.TransmissionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(transmissions);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransmissionsExists(transmissions.TransmissionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(transmissions));
        }
Exemplo n.º 8
0
 private static void UpdateOpenCamTable()
 {
     lock (OPCObjects.OPCLocker)
     {
         lock (OPCObjects.SQLLocker)
         {
             using (var context = new MyDBContext())
             {
                 var opcopencamtable = Objects.OPCObjects.createObjects().GetOpenCam();
                 var opencamvalues   = context.OpenCam.Where(e => e.Id == 1);
                 foreach (var oc in opencamvalues)
                 {
                     oc.Access         = opcopencamtable.Access;
                     oc.Heat_cam       = opcopencamtable.Heat_cam;
                     oc.Stage_1_done   = opcopencamtable.Stage_1_done;
                     oc.Stage_1_Return = opcopencamtable.Stage_1_Return;
                     oc.Stage_1_stage  = opcopencamtable.Stage_1_stage;
                     context.Update(oc);
                 }
                 context.SaveChanges();
                 context.Dispose();
             }
         }
     }
 }
Exemplo n.º 9
0
        public async Task <IActionResult> Edit(int id, [Bind("BookID,Title")] Book book)
        {
            if (id != book.BookID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.BookID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
        public async Task <IActionResult> Edit(int id, [Bind("GuestID,_guestName,_guestPhone,_guestEmail")] Guest guest)
        {
            if (id != guest.GuestID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(guest);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GuestExists(guest.GuestID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(guest));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Edit(int id, [Bind("MaLoai,TenLoai")] Loai loai)
        {
            if (id != loai.MaLoai)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(loai);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoaiExists(loai.MaLoai))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(loai));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Edit(int id, [Bind("StudentID,Name,SurName,Age")] Student student)
        {
            if (id != student.StudentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.StudentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Exemplo n.º 13
0
        public async Task <IActionResult> Edit(int id, [Bind("GroupInfoId,GroupSize,StudentAuId,GroupId")] GroupInfo groupInfo)
        {
            if (id != groupInfo.GroupInfoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(groupInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupInfoExists(groupInfo.GroupInfoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"]     = new SelectList(_context.Set <Group>(), "GroupId", "GroupId", groupInfo.GroupId);
            ViewData["StudentAuId"] = new SelectList(_context.Students, "StudentAuId", "FirstName", groupInfo.StudentAuId);
            return(View(groupInfo));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,FechaEstreno,CantidadEnStock,GeneroId")] Pelicula pelicula)
        {
            if (id != pelicula.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pelicula);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PeliculaExists(pelicula.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GeneroId"] = new SelectList(_context.Set <Genero>(), "Id", "Nombre", pelicula.GeneroId);
            return(View(pelicula));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Edit(int id, [Bind("MaMon,TenMon,SoTinChi,MaKhoa")] MonHoc monHoc)
        {
            if (id != monHoc.MaMon)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(monHoc);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MonHocExists(monHoc.MaMon))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaKhoa"] = new SelectList(_context.Khoas, "MaKhoa", "TenKhoa", monHoc.MaKhoa);
            return(View(monHoc));
        }
Exemplo n.º 16
0
 private static void UpdateFVP()
 {
     lock (OPCObjects.OPCLocker)
     {
         lock (OPCObjects.SQLLocker)
         {
             using (var context = new MyDBContext())
             {
                 var entitys = context.FVP.Where(e => e.Id == 1);
                 foreach (var entity in entitys)
                 {
                     entity.Auto_mode    = OPCObjects.FVPStatus.Auto_mode;
                     entity.Block        = OPCObjects.FVPStatus.Block;
                     entity.Manual_start = OPCObjects.FVPStatus.Manual_start;
                     entity.Power_On     = OPCObjects.FVPStatus.Power_On;
                     entity.Remote       = OPCObjects.FVPStatus.Remote;
                     entity.Start        = OPCObjects.FVPStatus.Start;
                     entity.Turn_On      = OPCObjects.FVPStatus.Turn_On;
                     context.Update(entity);
                 }
                 context.SaveChanges();
                 context.Dispose();
             }
         }
     }
 }
Exemplo n.º 17
0
 private static void UpdateValves()
 {
     lock (OPCObjects.OPCLocker)
     {
         lock (OPCObjects.SQLLocker)
         {
             using (var context = new MyDBContext())
             {
                 foreach (var valve in OPCObjects.ValvesInput)
                 {
                     var entitys = context.Valve.Where(e => e.Id == valve.Key);
                     foreach (var entity in entitys)
                     {
                         entity.viAuto_mode    = valve.Value.Auto_mode;
                         entity.viMan_command  = valve.Value.Man_command;
                         entity.viService_mode = valve.Value.Service_mode;
                         entity.vsBlocked      = OPCObjects.ValvesStatus[valve.Key].Blocked;
                         entity.vsClosed       = OPCObjects.ValvesStatus[valve.Key].Closed;
                         entity.vsClosing      = OPCObjects.ValvesStatus[valve.Key].Closing;
                         entity.vsOpened       = OPCObjects.ValvesStatus[valve.Key].Opened;
                         entity.vsOpening      = OPCObjects.ValvesStatus[valve.Key].Opening;
                         entity.vsServiced     = OPCObjects.ValvesStatus[valve.Key].Serviced;
                         context.Update(entity);
                     }
                 }
                 context.SaveChanges();
                 context.Dispose();
             }
         }
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("OderID,Quantity,Gia,MaHH")] OderDetail oderDetail)
        {
            if (id != oderDetail.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(oderDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OderDetailExists(oderDetail.OderID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(oderDetail));
        }
Exemplo n.º 19
0
        public async Task <IActionResult> Edit(Customer customer, string NameImage, string NameFolder)
        {
            var info = HttpContext.Session.GetObject <Employee>("Employee");

            if (info == null)
            {
                return(BadRequest(new { message = "login" }));
            }
            MyTool.MoveImage("Customer", NameImage, NameFolder);

            var cus = await _context.Customer.AsNoTracking().SingleOrDefaultAsync(e => e.CustomerId == customer.CustomerId);

            if (customer.Password != cus.Password)
            {
                customer.Password = MyHashTool.GetMd5Hash(customer.Password);
            }

            if (ModelState.IsValid)
            {
                try
                {
                    customer.Image = NameImage;
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch
                {
                    return(BadRequest(new { content = "Sửa không thành công!!!" }));
                }
                var model = await _context.Customer.AsNoTracking().ToListAsync();

                return(View("Datatable", model));
            }
            return(View(customer));
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,EstaSubscrito,TipoMembresiaId")] Cliente cliente)
        {
            if (id != cliente.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TipoMembresiaId"] = new SelectList(_context.Set <TipoMembresia>(), "Id", "Id", cliente.TipoMembresiaId);
            return(View(cliente));
        }
Exemplo n.º 21
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,LabelId,BodyId,ColorId,Year,TransmissionId,Price,LandlordId,GovNumber")] Cars cars)
        {
            if (id != cars.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cars);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarsExists(cars.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BodyId"]         = new SelectList(_context.Bodies, "BodyId", "Body", cars.BodyId);
            ViewData["ColorId"]        = new SelectList(_context.Colors, "ColorId", "Color", cars.ColorId);
            ViewData["LabelId"]        = new SelectList(_context.Labels, "LableId", "Lable", cars.LabelId);
            ViewData["LandlordId"]     = new SelectList(_context.Landlords, "Id", "Name", cars.LandlordId);
            ViewData["TransmissionId"] = new SelectList(_context.Transmissions, "TransmissionId", "Trasmission", cars.TransmissionId);
            return(View(cars));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Edit(int id, [Bind("StudentAuId,FirstName,LastName,EnrolledDate,GradulationDate,Grade,isActive")] Student student)
        {
            if (id != student.StudentAuId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.StudentAuId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Exemplo n.º 23
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Status,CustomerID,ShipName,ShipMobile,ShipAddress,ShipEmail,CreatedDate")] Oder oder)
        {
            if (id != oder.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(oder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OderExists(oder.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(oder));
        }
Exemplo n.º 24
0
        public async Task <IActionResult> Edit(int id, [Bind("EmployeeID,FirstName,LastName,DepartmentID")] Employee employee)
        {
            if (id != employee.EmployeeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.EmployeeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentID"] = new SelectList(_context.Department, "DepartmentID", "DepartmentID", employee.DepartmentID);
            return(View(employee));
        }
Exemplo n.º 25
0
        public IActionResult ReplyFeedBack([Bind("FeedbackId")] int?id, [Bind("ReplySubject")] string ReplySubject, [Bind("ReplyContext")] string ReplyContext)
        {
            Feedback feedback = _ctx.Feedback.SingleOrDefault(p => p.FeedbackId == id);

            if (feedback == null)
            {
                return(NotFound());
            }
            else
            {
                var emp = HttpContext.Session.GetObject <Employee>("Employee");
                if (emp != null)
                {
                    feedback.EmployeeId   = emp.EmployeeId;
                    feedback.ReplyDone    = true;
                    feedback.ReplySubject = ReplySubject;
                    feedback.ReplyContext = ReplyContext;
                    feedback.ReplyDate    = DateTime.Now;
                    GoogleMailer.Send(feedback.Email, ReplySubject, ReplyContext);
                    _ctx.Update(feedback);
                    _ctx.SaveChanges();
                }
                else
                {
                    TempData["ReturnUrl"] = "/Admin/Feedback/ReplyFeedBack/" + id;
                    return(RedirectToAction("Index", "Login"));
                }
            }
            ViewBag.Result = "Phản hồi thành công!!!";
            return(View(feedback));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] Pelicula pelicula)
        {
            if (id != pelicula.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pelicula);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PeliculaExists(pelicula.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pelicula));
        }
Exemplo n.º 27
0
        private static void HandleAnalogDataChange(object sender, OpcDataChangeReceivedEventArgs e)
        {
            OpcMonitoredItem item = (OpcMonitoredItem)sender;

            Console.WriteLine(
                "Data Change from NodeId '{0}': {1}",
                item.RelativePath,
                e.Item.Value);
            var objects = Objects.OPCObjects.createObjects();

            using (var context = new MyDBContext())
            {
                lock (objects.getSQLLocker())
                {
                    var analogs = context.AnalogValue.Where(x => x.Path == item.NodeId);
                    foreach (var analog in analogs)
                    {
                        var input = e.Item.Value.ToString();
                        analog.Value = float.Parse(input);
                        context.Update(analog);
                        context.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Edit(int id, [Bind("ColorId,Color")] Colors colors)
        {
            if (id != colors.ColorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(colors);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ColorsExists(colors.ColorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(colors));
        }
Exemplo n.º 29
0
 public async Task <IActionResult> Edit(int?id, HangHoa model,
                                        IFormFile fHinh)
 {
     if (fHinh != null)
     {
         //upload file
         var path = Path.Combine(Directory.GetCurrentDirectory(),
                                 @"wwwroot\Hinh", fHinh.FileName);
         using (var file = new FileStream(path, FileMode.Create))
         {
             await fHinh.CopyToAsync(file);
         }
         model.Hinh = fHinh.FileName;
     }
     if (id.HasValue && id.Value > 0)
     {
         _context.Update(model);
     }
     else
     {
         _context.Add(model);
     }
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 30
0
 private static void UpdateCrioPump()
 {
     lock (OPCObjects.OPCLocker)
     {
         lock (OPCObjects.SQLLocker)
         {
             using (var context = new MyDBContext())
             {
                 var entitys = context.CrioPump.Where(e => e.Id == 1);
                 foreach (var entity in entitys)
                 {
                     entity.iAuto_mode      = OPCObjects.CrioInput.Auto_mode;
                     entity.iCommand_manual = OPCObjects.CrioInput.Command_manual;
                     entity.sAuto_mode      = OPCObjects.CrioStatus.Auto_mode;
                     entity.sBlocked        = OPCObjects.CrioStatus.Blocked;
                     entity.sError          = OPCObjects.CrioStatus.Error;
                     entity.sPower_On       = OPCObjects.CrioStatus.Power_On;
                     entity.sTurn_On        = OPCObjects.CrioStatus.Turn_On;
                     context.Update(entity);
                 }
                 context.SaveChanges();
                 context.Dispose();
             }
         }
     }
 }