예제 #1
0
        public void Update(Data.Models.Machine machine, int userId)
        {
            Data.Models.Machine oldMachine = _machineRepository.Table.Where(w => w.Id == machine.Id).FirstOrDefault();
            if (oldMachine != null)
            {
                if (machine.IsActive != oldMachine.IsActive)
                {
                    this._lineMachineActiveHistoryRepository.Insert(new LineMachineActiveHistory
                    {
                        LineId     = machine.LineId,
                        MachineId  = machine.Id,
                        IsActive   = machine.IsActive,
                        UpdateBy   = userId,
                        UpdateDate = DateTime.UtcNow,
                    });
                }

                oldMachine.Name             = machine.Name;
                oldMachine.Make             = machine.Make;
                oldMachine.Model            = machine.Model;
                oldMachine.MachineInCharge  = machine.MachineInCharge;
                oldMachine.InstallationDate = machine.InstallationDate;
                oldMachine.MachineType      = machine.MachineType;
                oldMachine.Description      = machine.Description;
                oldMachine.ParentId         = machine.ParentId;
                oldMachine.PlantId          = machine.PlantId;
                oldMachine.MachineTypeId    = machine.MachineTypeId;
                oldMachine.LineId           = machine.LineId;
                oldMachine.IsActive         = machine.IsActive;
                _machineRepository.Update(oldMachine);
            }
        }
예제 #2
0
        public void UpdateIsShutdown(int machineId, bool IsShutdown)
        {
            Data.Models.Machine oldMachine = _machineRepository.Table.Where(w => w.Id == machineId).FirstOrDefault();

            if (oldMachine != null)
            {
                oldMachine.IsShutdown = IsShutdown;
                _machineRepository.Update(oldMachine);
            }
        }
예제 #3
0
        public JsonResult AddMachine(Data.Models.Machine machine)
        {
            var result = new { Success = "true", Message = "Success" };

            try
            {
                this._machineService.Add(machine);
            }
            catch (Exception ex)
            {
                result = new { Success = "false", Message = "Problem in adding Machine.Please contact Admin." };
            }
            //return View("List");
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        //public int GetPlantIdByLineId(int LineId)
        //{
        //    return _machineRepository.Table.Where(w=>w.LineId==LineId).Select(s => s.Line.PlantId.Value).FirstOrDefault();
        //}

        //public int GetSiteIdByLineId(int LineId)
        //{
        //    return _machineRepository.Table.Where(w => w.LineId == LineId).Select(s => s.Line.Plant.SiteId.Value).FirstOrDefault();
        //}
        public int[] Delete(int[] ids)
        {
            List <int> machineIds = new List <int>();

            foreach (int id in ids)
            {
                //if (_machineRepository.Table.Any(a => a.SubAssemblies.Any(b => b.MachineId == id)))
                //    machineIds.Add(id);
                //else
                //{
                Data.Models.Machine Machine = _machineRepository.Table.FirstOrDefault(w => w.Id == id);
                _machineRepository.Delete(Machine);
                //}
            }
            return(machineIds.ToArray());
        }
예제 #5
0
        public JsonResult UpdateMachine(Data.Models.Machine machine)
        {
            var result = new { Success = "true", Message = "Success" };
            int userId = HttpContext.User.Identity.GetUserId <int>();

            try
            {
                this._machineService.Update(machine, userId);
            }
            catch (Exception ex)
            {
                result = new { Success = "false", Message = "Problem in updating Machine.Please contact Admin." };
            }
            //return View("List");
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
 public int Add(Data.Models.Machine machine)
 {
     _machineRepository.Insert(machine);
     return(machine.Id);
 }