Example #1
0
        public ResponseObject <bool> UpdateDevice(AgencyDeviceAPIViewModel model)
        {
            var deviceService = this.Service <IDeviceService>();

            var result = deviceService.UpdateDevice(model);

            return(result);
        }
Example #2
0
 public ResponseObject <AgencyDeviceAPIViewModel> GetDeviceByDeviceId(int deviceId)
 {
     try
     {
         var deviceRepo = DependencyUtils.Resolve <IDeviceRepository>();
         var devices    = deviceRepo.GetActive().SingleOrDefault(a => a.DeviceId == deviceId);
         if (devices == null)
         {
             return(new ResponseObject <AgencyDeviceAPIViewModel> {
                 IsError = true, WarningMessage = "Không tìm thấy thiết bị!", ObjReturn = null
             });
         }
         var agencyDeviceAPIViewModel = new AgencyDeviceAPIViewModel
         {
             DeviceId          = devices.DeviceId,
             AgencyId          = devices.AgencyId,
             DeviceTypeId      = devices.DeviceTypeId,
             DeviceName        = devices.DeviceName,
             DeviceCode        = devices.DeviceCode,
             GuarantyStartDate = devices.GuarantyStartDate != null?devices.GuarantyStartDate.Value.ToString("HH:mm dd/MM/yyyy") : string.Empty,
                                     GuarantyEndDate                                                                                        = devices.GuarantyEndDate != null?devices.GuarantyEndDate.Value.ToString("HH:mm dd/MM/yyyy") : string.Empty,
                                                                                              Ip                                            = devices.Ip,
                                                                                              Port                                          = devices.Port,
                                                                                              DeviceAccount                                 = devices.DeviceAccount,
                                                                                              DevicePassword                                = devices.DevicePassword,
                                                                                              SettingDate                                   = devices.SettingDate != null?devices.SettingDate.Value.ToString("HH:mm dd/MM/yyyy") : string.Empty,
                                                                                                                                 Other      = devices.Other,
                                                                                                                                 CreateDate = devices.CreateDate.ToString("HH:mm dd/MM/yyyy"),
                                                                                                                                 UpdateDate = devices.UpdateDate != null?devices.UpdateDate.Value.ToString("HH:mm dd/MM/yyyy") : string.Empty
         };
         return(new ResponseObject <AgencyDeviceAPIViewModel> {
             IsError = false, SuccessMessage = "Tìm thấy thiết bị!", ObjReturn = agencyDeviceAPIViewModel
         });
     }
     catch (Exception e)
     {
         return(new ResponseObject <AgencyDeviceAPIViewModel> {
             IsError = true, WarningMessage = "Không tìm thấy thiết bị!", ObjReturn = null, ErrorMessage = e.ToString()
         });
     }
 }
Example #3
0
        public ResponseObject <bool> UpdateDevice(AgencyDeviceAPIViewModel model)
        {
            try
            {
                var deviceRepo   = DependencyUtils.Resolve <IDeviceRepository>();
                var updateDevice = deviceRepo.GetActive().SingleOrDefault(a => a.DeviceId == model.DeviceId);

                if (updateDevice != null)
                {
                    updateDevice.DeviceTypeId      = model.DeviceTypeId;
                    updateDevice.DeviceName        = model.DeviceName;
                    updateDevice.DeviceCode        = model.DeviceCode;
                    updateDevice.GuarantyStartDate = model.GuarantyStartDate.ToDateTime();
                    updateDevice.GuarantyEndDate   = model.GuarantyEndDate.ToDateTime();
                    updateDevice.Ip             = model.Ip;
                    updateDevice.Port           = model.Port;
                    updateDevice.DeviceAccount  = model.DeviceAccount;
                    updateDevice.DevicePassword = model.DevicePassword;
                    updateDevice.Other          = model.Other;
                    updateDevice.UpdateDate     = DateTime.UtcNow.AddHours(7);

                    deviceRepo.Edit(updateDevice);
                    deviceRepo.Save();
                    return(new ResponseObject <bool> {
                        IsError = false, SuccessMessage = "Chỉnh sửa thiết bị thành công", ObjReturn = true
                    });
                }

                return(new ResponseObject <bool> {
                    IsError = true, WarningMessage = "Chỉnh sửa thiết bị thất bại", ObjReturn = false
                });
            }
            catch (Exception e)
            {
                return(new ResponseObject <bool> {
                    IsError = true, WarningMessage = "Chỉnh sửa thiết bị thất bại", ObjReturn = false, ErrorMessage = e.ToString()
                });
            }
        }
        public ActionResult UpdateDevice(AgencyDeviceAPIViewModel model)
        {
            var result = _deviceDomain.UpdateDevice(model);

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