/// <summary> /// Manage user group /// </summary> /// <param name="operation">the operation</param> /// <param name="model">the user group model</param> /// <returns></returns> public ResponseModel ManageRotatingImageGroup(GridOperationEnums operation, RotatingImageGroupModel model) { ResponseModel response; Mapper.CreateMap <RotatingImageGroupModel, RotatingImageGroup>(); RotatingImageGroup rotatingImageGroup; switch (operation) { case GridOperationEnums.Edit: rotatingImageGroup = _rotatingImageGroupRepository.GetById(model.Id); rotatingImageGroup.Name = model.Name; rotatingImageGroup.RecordOrder = model.RecordOrder; rotatingImageGroup.RecordActive = model.RecordActive; response = Update(rotatingImageGroup); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::UpdateSuccessfully:::Update group successfully.") : _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::UpdateFailure:::Update group failed. Please try again later."))); case GridOperationEnums.Add: rotatingImageGroup = Mapper.Map <RotatingImageGroupModel, RotatingImageGroup>(model); rotatingImageGroup.Settings = string.Empty; var groupSettingModel = new GroupSettingModel(); rotatingImageGroup.Settings = SerializeUtilities.SerializeObject(groupSettingModel); response = Insert(rotatingImageGroup); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::CreateSuccessfully:::Create group successfully") : _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::CreateFailure:::Insert group failed. Please try again later."))); case GridOperationEnums.Del: response = Delete(model.Id); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::DeleteSuccessfully:::Delete group successfully.") : _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::DeleteFailure:::Delete group failed. Please try again later."))); } return(new ResponseModel { Success = false, Message = _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::ObjectNotFounded:::Rotating Image Group is not founded.") }); }
/// <summary> /// Get item /// </summary> /// <param name="model">Group setting model</param> /// <returns>GroupSettingModel</returns> public GroupSettingModel GetItemByID(GroupSettingModel model) { try { using (var _context = new TDHEntities()) { MN_GROUP_SETTING _md = _context.MN_GROUP_SETTING.FirstOrDefault(m => m.id == model.ID && !m.deleted && m.create_by == model.CreateBy); if (_md == null) { throw new DataAccessException(FILE_NAME, "GetItemByID", model.CreateBy); } var _group = _context.MN_GROUP.FirstOrDefault(m => m.id == _md.group_id); return(new GroupSettingModel() { ID = _md.id, GroupID = _md.group_id, GroupName = _group.name, YearMonth = _md.year_month, PercentCurrent = _md.percent_current, PercentSetting = _md.percent_setting, MoneyCurrent = _md.money_current, MoneyCurrentString = _md.money_current.NumberToString(), MoneySetting = _md.money_setting, MoneySettingString = _md.money_setting.NumberToString() }); } } catch (DataAccessException fieldEx) { throw fieldEx; } catch (Exception ex) { throw new ServiceException(FILE_NAME, "GetItemByID", model.CreateBy, ex); } }