Ejemplo n.º 1
0
        public dynamic Update(FPMachine model)
        {
            model.Errors = new Dictionary <string, string>();
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.FPMachine, Core.Constants.Constant.MenuGroupName.Setting))
                {
                    model.Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        model
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _fpMachineService.GetObjectById(model.Id);
                data.CompanyInfoId = model.CompanyInfoId;
                data.MachineName   = model.MachineName;
                if (!data.IsConnected)
                {
                    data.MachineNumber = model.MachineNumber;
                }
                data.Password                = model.Password;
                data.CommType                = model.CommType;
                data.EthernetIP              = model.EthernetIP;
                data.EthernetPort            = model.EthernetPort;
                data.SerialPort              = model.SerialPort;
                data.SerialBaudRate          = model.SerialBaudRate;
                data.IsClearLogAfterDownload = model.IsClearLogAfterDownload;
                data.TimeZone                = model.TimeZone; // GeneralFunction.IanaToWindows(model.TimeZone);
                data.TimeZoneOffset          = model.TimeZoneOffset;

                model = _fpMachineService.UpdateObject(data, _companyInfoService);
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                model.Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    model
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model
            }));
        }