public ResponseObject <bool> CreateDeviceType(DeviceTypeAPIViewModel model)
        {
            var devicetypeRepo   = DependencyUtils.Resolve <IDeviceTypeRepository>();
            var createDeviceType = new DeviceType();

            try
            {
                createDeviceType.DeviceTypeId   = model.DeviceTypeId;
                createDeviceType.ServiceId      = model.ServiceId;
                createDeviceType.DeviceTypeName = model.DeviceTypeName;
                createDeviceType.Description    = model.Description;
                createDeviceType.IsDelete       = false;
                createDeviceType.CreateDate     = DateTime.UtcNow.AddHours(7);
                createDeviceType.UpdateDate     = DateTime.UtcNow.AddHours(7);

                devicetypeRepo.Add(createDeviceType);

                devicetypeRepo.Save();
                return(new ResponseObject <bool> {
                    IsError = false, SuccessMessage = "Thêm loại thiết bị thành công", ObjReturn = true
                });
            }
            catch (Exception ex)
            {
                return(new ResponseObject <bool> {
                    IsError = true, WarningMessage = "Thêm loại thiết bị thất bại", ErrorMessage = ex.ToString(), ObjReturn = false
                });
            }
        }
        public ResponseObject <DeviceTypeAPIViewModel> ViewDetail(int devicetype_id)
        {
            var devicetypeRepo = DependencyUtils.Resolve <IDeviceTypeRepository>();
            var devicetype     = devicetypeRepo.GetActive().SingleOrDefault(a => a.DeviceTypeId == devicetype_id);

            if (devicetype != null)
            {
                var devicetypeAPIViewModel = new DeviceTypeAPIViewModel
                {
                    DeviceTypeId   = devicetype.DeviceTypeId,
                    DeviceTypeName = devicetype.DeviceTypeName,
                    ServiceId      = devicetype.ServiceId,
                    ServiceName    = devicetype.ServiceITSupport.ServiceName,
                    Description    = devicetype.Description,
                    CreateDate     = devicetype.CreateDate.ToString("dd/MM/yyyy"),
                    UpdateDate     = devicetype.UpdateDate.Value.ToString("dd/MM/yyyy"),
                };
                return(new ResponseObject <DeviceTypeAPIViewModel> {
                    IsError = false, ObjReturn = devicetypeAPIViewModel, SuccessMessage = "Lấy chi tiết thành công"
                });
            }
            return(new ResponseObject <DeviceTypeAPIViewModel> {
                IsError = true, WarningMessage = "Không tồn tại loại thiết bị này"
            });
        }
示例#3
0
        public ResponseObject <bool> UpdateDeviceType(DeviceTypeAPIViewModel model)
        {
            var deviceTypeService = this.Service <IDeviceTypeService>();

            var result = deviceTypeService.UpdateDeviceType(model);

            return(result);
        }
        public ResponseObject <bool> UpdateDeviceType(DeviceTypeAPIViewModel model)
        {
            var devicetypeRepo   = DependencyUtils.Resolve <IDeviceTypeRepository>();
            var updateDeviceType = devicetypeRepo.GetActive().SingleOrDefault(a => a.DeviceTypeId == model.DeviceTypeId);

            if (updateDeviceType != null)
            {
                updateDeviceType.ServiceId      = model.ServiceId;
                updateDeviceType.DeviceTypeName = model.DeviceTypeName;
                updateDeviceType.Description    = model.Description;
                updateDeviceType.UpdateDate     = DateTime.UtcNow.AddHours(7);

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

            return(new ResponseObject <bool> {
                IsError = true, WarningMessage = "Chỉnh sửa loại thiết bị thất bại", ObjReturn = false
            });
        }
        public ActionResult UpdateDeviceType(DeviceTypeAPIViewModel model)
        {
            var result = _devicetypeDomain.UpdateDeviceType(model);

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