public void WHEN_Convert_GIVEN_Valid_Dto_THEN_Get_Valid_Result_With_All_Links() { var uniqueIdFactory = SampleObjectsIdFactory.Instance; var fieldDto = new FieldDto { Uid = Guid.NewGuid(), FarmUid = Guid.NewGuid(), GrowerUid = Guid.NewGuid(), Name = "Test" }; var converter = new FieldDtoConverter(uniqueIdFactory); var field = converter.Convert(fieldDto); Assert.Equal(fieldDto.Uid.ToString(), field.Object.Id.UniqueIds.First().Id); Assert.Equal(fieldDto.Name, field.Object.Description); var selfLink = field.Links.Single(l => l.Rel == Relationships.Self); Assert.Equal($"/Fields/{uniqueIdFactory.UniqueIdSource}/{fieldDto.Uid}", selfLink.Link); Assert.Equal(selfLink.Id.ReferenceId, field.Object.Id.ReferenceId); var growerLink = field.Links.Single(l => l.Rel == typeof(Grower).ObjectRel()); Assert.Equal($"/Growers/{uniqueIdFactory.UniqueIdSource}/{fieldDto.GrowerUid}", growerLink.Link); var farmLink = field.Links.Single(l => l.Rel == typeof(Farm).ObjectRel()); Assert.Equal($"/Farms/{uniqueIdFactory.UniqueIdSource}/{fieldDto.FarmUid}", farmLink.Link); var cropZoneLink = field.Links.Single(l => l.Rel == typeof(CropZone).ListRel()); Assert.Equal($"/Fields/{uniqueIdFactory.UniqueIdSource}/{fieldDto.Uid}/CropZones", cropZoneLink.Link); var boundaryLink = field.Links.Single(l => l.Rel == typeof(FieldBoundary).ListRel()); Assert.Equal($"/Fields/{uniqueIdFactory.UniqueIdSource}/{fieldDto.Uid}/FieldBoundaries", boundaryLink.Link); }
private int GetColumnsCountCorrespondingToSurvayQuestion(FieldDto question) { try { var columnsCount = 0; if (question.Field_Type.ToLower() == "checkboxes" || question.Field_Type.ToLower() == "checkwithtext") { if (question.FieldOption.Include_other_option) { columnsCount++; } columnsCount += question.FieldOption.Options.Count(); } else if (question.Field_Type.ToLower() == "mulitiselect-matrix" || question.Field_Type.ToLower() == "single-matrix") { columnsCount = question.FieldOption.MatrixRows.Count() * question.FieldOption.MatrixHeaders.Count(); } else { columnsCount++; } return(columnsCount); } catch (Exception e) { _log.Error(e); return(0); } }
private List <FieldDto> LoadFieldValues(SyncItem syncItem) { var fields = new List <FieldDto>(); foreach (var field in syncItem.SharedFields) { var fieldDto = new FieldDto { Id = Guid.Parse(field.FieldID), Value = field.FieldValue }; fields.Add(fieldDto); } foreach (var version in syncItem.Versions) { foreach (var field in version.Fields) { var fieldDto = new FieldDto { Id = Guid.Parse(field.FieldID), Value = field.FieldValue, Language = version.Language, Version = int.Parse(version.Version) }; fields.Add(fieldDto); } } return(fields); }
public void WhenDeletingAPassword_ItShouldBeDeleted() { // Given IDatastore originalDatastore = null; AccountDto twitterAccount = null; FieldDto originalPasswordDto = null; FieldDto changedPasswordDto = FakeData.FakeDataGenerator.GetFacebookPassword(); // When TestWithPrepopulatedDatastore(dataStore => { originalDatastore = dataStore; twitterAccount = dataStore.GetAccountDtos().First(account => account.ProviderKey == FakeData.FakeDataGenerator.TwitterProviderKey); originalPasswordDto = twitterAccount.Fields.Single(field => field.FieldTypeKey == "pin"); twitterAccount.Fields.Remove(originalPasswordDto); twitterAccount.Fields.Add(changedPasswordDto); originalDatastore.SaveAccountDto(twitterAccount); }); // Then originalDatastore.GetAccountDto(twitterAccount.Id).Fields.Should().NotContain(originalPasswordDto); originalDatastore.GetAccountDto(twitterAccount.Id).Fields.Should().Contain(changedPasswordDto); }
public JsonResult Update(FieldDto dto) { dto.AdminId = AuthorityHelper.OperatorId ?? 0; OperationResult oper = _fieldContract.Update(dto); return(Json(oper)); }
private static Field ToField(FieldDto field) { switch (field.Type) { case FieldType.SingleLine: return(new SingleLineTextField { Label = field.Label, Text = field.Data }); case FieldType.Multiline: return(new MultiLineTextField { Label = field.Label, Text = field.Data }); case FieldType.Password: return(new PasswordField { Label = field.Label, Text = field.Data }); default: throw new NotSupportedException(); } }
private static void ProcessFields(CheckOptions checkOptions, System.Collections.Generic.List <FieldInfo> fields, int fieldsCount, TypeDto typeDto) { for (int n = 0; n < fieldsCount; n++) { var fInfo = fields[n]; var fDto = new FieldDto { Name = fInfo.ToString() }; typeDto.Fields.Add(fDto); if (!checkOptions.LogOnlyMissing) { Log.Write(Verbosity.Normal, LogLevel.Information, " Processing field {0} of {1}", n + 1, fieldsCount); } var fieldDocXml = DocsService.GetXmlFromMember(fInfo, false); fDto.XmlDescription = GetInnerText(fieldDocXml); if (string.IsNullOrEmpty(fDto.XmlDescription)) { Log.Write(Verbosity.Normal, LogLevel.Warning, " FIELD: {0} XML: {1}", fDto.Name, MISSING_XML); } else if (!checkOptions.LogOnlyMissing) { Log.Write(Verbosity.Normal, LogLevel.Information, " FIELD: {0} XML: {1}", fDto.Name, fDto.XmlDescription); } } }
internal void Update(AccountDto accountDto) { if (accountDto.Id != Id) { throw new Exception("Cannot update a different DTO, ID don't match"); } ; accountDto.Fields.Clear(); foreach (var field in Fields) { var fieldDto = new FieldDto { Id = field.Id, FieldTypeKey = field.FieldType.Key.ToString(), Name = field.Name, Value = field.Value }; accountDto.Fields.Add(fieldDto); } accountDto.Tags.Clear(); foreach (var tag in Tags) { accountDto.Tags.Add(new TagDto { Key = tag.Key }); } accountDto.Notes = Notes; }
public async Task <FieldDto> GetField(FieldDto input) { var query = await _fieldRepository.SingleAsync(c => c.Id == input.Id); var data = query.MapTo <FieldDto>(); return(data); }
public ActionResult Add() { var fieldDto = new FieldDto { Departments = new SelectList(departmentService.GetDepartments(), "Id", "Name"), }; return(View(fieldDto)); }
public BookingViewModel(FieldDto fieldDto, string storeName) { _reservationServices = DependencyService.Get <IReservationServices>(); _fieldServices = DependencyService.Get <IFieldServices>(); BookCommand = new Command(async() => await ExecuteBookCommand(fieldDto)); Task.Run(async() => await ExecuteLoadItemsCommand(fieldDto, StoreName)); }
public async Task UpdateAsync(FieldDto fieldDto) { var field = await _repository.GetAsync(fieldDto.Id); if (field == null) { throw new GreenFieldNotFoundException(); } field = _mapper.Map <Field>(fieldDto); await _repository.UpdateAsync(field); }
async Task ExecuteBookCommand(FieldDto fieldDto) { try { //IsBusy = true; var userId = Preferences.Get(AuthorizeConstants.UserIdKey, string.Empty); var storeId = Preferences.Get(AuthorizeConstants.StoreIdKey, string.Empty); var request = new ReservationRequest { StoreId = Convert.ToInt32(storeId), UserId = Convert.ToInt32(userId), FieldId = fieldDto.Id.Value, StartTime = new DateTime(SelectedDate.Year, SelectedDate.Month, SelectedDate.Day, FromTime.Hours, FromTime.Minutes, 0), StopTime = new DateTime(SelectedDate.Year, SelectedDate.Month, SelectedDate.Day, ToTime.Hours, ToTime.Minutes, 0), }; var start = request.StartTime.Value.ToString("MM/dd/yyyy h:mm tt"); var stop = request.StopTime.Value.ToString("MM/dd/yyyy h:mm tt"); bool answer = await Shell.Current.DisplayAlert("แจ้งเตือน!", $"\n ชื่อร้านที่จอง: {StoreName} \n ชื่อสนามที่จอง: {NameField} \n ราคา : {Price} \n ขนาดของสนาม : {SizeField} \n ตั้งแต่ : {start} \n " + $"ถึง : {stop}\n", "ใช่", "ไม่"); if (!answer) { return; } var result = await _reservationServices.CreateReservation(request); if (result) { await Shell.Current.DisplayAlert("แจ้งเตือน!", "ทำรายการจองเรียบร้อยแล้ว", "ตกลง"); await Shell.Current.Navigation.PopAsync(); } else { await Shell.Current.DisplayAlert("ไม่สามารถจองได้ในขณะนี้", "กรุณารลองใหม่ภายหลัง", "ตกลง"); } } catch (Exception ex) { throw ex; } finally { IsBusy = false; } }
public void Field() { var state = FieldState.Flag; var value = 5; var board = new FieldDto() { State = FieldState.Flag, Value = value }; Assert.IsTrue(board.State == state); Assert.IsTrue(board.Value == value); }
public void Fail_WhenNewFieldLabelsNotUnique() { var secondField = new FieldDto { Label = _newField.Label }; _dto.NewFields.Add(secondField); var result = _dut.Validate(_dto); Assert.IsFalse(result.IsValid); Assert.IsTrue(result.Errors.Single().ErrorMessage == "Cannot have duplicate field labels"); }
public void Constructor_ShouldSetProperties() { var dut = new FieldDto(1, "LabelA", true, FieldType.CheckBox, 10, "UnitA", true, _rowVersion); Assert.AreEqual(1, dut.Id); Assert.AreEqual("LabelA", dut.Label); Assert.AreEqual("UnitA", dut.Unit); Assert.AreEqual(FieldType.CheckBox, dut.FieldType); Assert.AreEqual(10, dut.SortKey); Assert.IsTrue(dut.ShowPrevious.HasValue); Assert.IsTrue(dut.ShowPrevious.Value); Assert.IsTrue(dut.IsVoided); Assert.AreEqual(_rowVersion, dut.RowVersion); }
public void CreateNewFieldDto(FieldDto fieldDto) { var field = Mapper.Map <Field>(fieldDto); //var field = new Field //{ // Name = fieldDto.Name, // Description = fieldDto.Description, // DepartmentId = fieldDto.DepartmentId, // CreatedDate = DateTime.Now, // CreatedBy = "test" //}; CreateNewField(field); }
public ActionResult Verify(int verifyType, params int[] Ids) { var res = new OperationResult(OperationResultType.Error); int countSuccess = 0; int countFail = 0; foreach (var item in Ids) { Field info = _fieldContract.Fields.Where(x => x.Id == item).FirstOrDefault(); if (info != null && info.VerifyType == 0) { FieldDto dto = new FieldDto(); dto.Id = item; dto.FieldReason = info.FieldReason; dto.StartTime = info.StartTime; dto.EndTime = info.EndTime; dto.FieldDays = info.FieldDays; dto.FieldWorkDays = info.FieldWorkDays; dto.VerifyType = verifyType; dto.AdminId = info.AdminId; dto.VerifyAdminId = AuthorityHelper.OperatorId; res = _fieldContract.Verify(dto); if (res.ResultType == OperationResultType.Success) { countSuccess++; string content = string.Empty; string title = "请假通知"; if (dto.VerifyType == (int)VerifyFlag.NoPass) { content = "审核不通过"; } else { content = "审核通过"; } EntityContract._notificationContract.SendNotice(dto.AdminId, title, content, sendNotificationAction); } else { countFail++; } } } var strResult = string.Format("操作完成:成功{0}个,失败{1}个", countSuccess, countFail); var oper = new OperationResult(OperationResultType.Success, strResult); return(Json(oper)); }
public ActionResult Update(FieldDto model) { try { fieldService.UpdateFieldDto(model); var successMessage = $"رشته {model.Name} با موفقیت ثبت شد"; return(Json(new { success = true, message = successMessage }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { var failMessage = "خطایی در ذخیره رخ داد، لطفا ورود داده را بررسی نمایید"; failMessage += $".<br /> code {ex.Message}"; return(Json(new { success = false, message = failMessage }, JsonRequestBehavior.AllowGet)); } }
public IList<FieldDto> GetFields(int campId) { try { IList<FieldDto> fieldDtos = new List<FieldDto>(); IList<Field> fields = fieldRepository.List(campId); foreach (Field field in fields) { FieldDto fieldDto = new FieldDto(field.Id, field.IsEnabled, campId); fieldDtos.Add(fieldDto); } return fieldDtos; } catch { throw; } }
public JsonResult Update(FieldDto dto) { dto.VerifyAdminId = AuthorityHelper.OperatorId; var res = _fieldContract.Verify(dto); string content = string.Empty; string title = "外勤通知"; if (dto.VerifyType == (int)VerifyFlag.NoPass) { content = "审核不通过"; } else { content = "审核通过"; } EntityContract._notificationContract.SendNotice(dto.AdminId, title, content, sendNotificationAction); return(Json(res, JsonRequestBehavior.AllowGet)); }
public void Setup() { _newField = new FieldDto { Label = "New", Unit = "U" }; _updateField = new UpdateFieldDto { Label = "Upd", Id = 2, Unit = "U" }; _dut = new UpdateRequirementDefinitionDtoValidator(); _dto = new UpdateRequirementDefinitionDto { DefaultIntervalWeeks = 1, NewFields = new List <FieldDto> { _newField }, Title = "T", SortKey = 2, UpdatedFields = new List <UpdateFieldDto> { _updateField } }; }
private JToken GenerateValue(FieldDto field) { switch (field.Properties) { case BooleanFieldPropertiesDto booleanField: { if (booleanField.IsRequired) { var value = random.Next(2); return(value == 1); } else { var value = random.Next(3); return(value switch { 1 => true, 2 => false, _ => null, }); }
public FieldDto Update(FieldDto input) { var deviceQuery = _deviceRepository.GetAll().Where(d => d.DeviceName == input.DeviceName); if (!deviceQuery.Any()) { throw new ApplicationException("设备不存在"); } var device = deviceQuery.FirstOrDefault(); var field = new Field() { FieldName = input.FieldName, IndexId = input.IndexId, Device = device, Id = input.Id }; var result = _fieldRepository.Update(field); CurrentUnitOfWork.SaveChanges(); return(ObjectMapper.Map <FieldDto>(result)); }
async Task ExecuteLoadItemsCommand(FieldDto fieldDto, string storeName) { IsBusy = true; try { SelectedDate = DateTime.Now; var data = await _fieldServices.GetFieldById(fieldDto.Id.Value); NameField = data.Name; Price = data.Price.Value.ToString() + " /ชม"; IsOpen = data.IsOpen == true ? IsOpen = "เปิดบริการ" : IsOpen = "ปิดบริการ"; SizeField = data.Size; StoreName = storeName; } catch (Exception ex) { throw ex; } finally { IsBusy = false; } }
public FieldDto Create(FieldDto input) { var fieldQuery = _fieldRepository.GetAll().Where(f => f.FieldName == input.FieldName); if ((fieldQuery.Any()) && (fieldQuery.FirstOrDefault().IsDeleted == true)) { var entity_old = fieldQuery.FirstOrDefault(); entity_old.IsDeleted = false; var result_old = _fieldRepository.Update(entity_old); CurrentUnitOfWork.SaveChanges(); return(ObjectMapper.Map <FieldDto>(result_old)); } if (fieldQuery.Any()) { throw new ApplicationException("field 已存在"); } var deviceQuery = _deviceRepository.GetAll().Where(d => d.DeviceName == input.DeviceName); if (!deviceQuery.Any()) { throw new ApplicationException("设备不存在"); } var device = deviceQuery.FirstOrDefault(); var field = new Field() { FieldName = input.FieldName, IndexId = input.IndexId, Device = device }; var result = _fieldRepository.Insert(field); CurrentUnitOfWork.SaveChanges(); return(ObjectMapper.Map <FieldDto>(result)); }
/// <summary> /// Gets field id. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> /// <param name="fieldId">The field id.</param> /// <param name="fieldDto">The field DTO.</param> /// <param name="stepFetchers">The step fetchers.</param> /// <param name="fieldEditorDto">The field editor DTO.</param> /// <returns>The Field Id.</returns> private static int? FieldId( ProcessEditDto process, SafeDataReader sr, int? fieldId, ref FieldDto fieldDto, Dictionary<string, IFetcher> stepFetchers, StepDto fieldEditorDto) { Profiler.Profile(() => sr.NextResult()); if (fieldId != fieldEditorDto.FieldId) { fieldId = fieldEditorDto.FieldId; fieldDto = process.Sections.SelectMany(s => s.FieldList).First(f => f.Id == fieldId); } fieldDto.Editors.Add((BaseStepDto) (stepFetchers.ContainsKey(fieldEditorDto.Class) ? stepFetchers[fieldEditorDto.Class].Fetch(fieldEditorDto, sr) : fieldEditorDto)); return fieldId; }
public JsonResult AddField(FieldDto dto) { OperationResult oper = oper = _fieldContract.Insert(dto); return(Json(oper)); }
public async Task CreateAsync(FieldDto fieldDto) { var field = _mapper.Map <Field>(fieldDto); await _repository.CreateAsync(field); }
/// <summary> /// Reads steps. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> /// <param name="stepList">The step list.</param> /// <param name="fieldId">The field id.</param> /// <param name="fieldDto">The field DTO.</param> /// <param name="stepFetchers">The step fetchers.</param> private static void ReadSteps( ProcessEditDto process, SafeDataReader sr, IEnumerable<StepDto> stepList, int? fieldId, FieldDto fieldDto, Dictionary<string, IFetcher> stepFetchers) { var t = new List<long>(); foreach (var fieldEditorDto in stepList) { try { var dto = fieldEditorDto; t.Add(Profiler.Profile(() => FieldId(process, sr, fieldId, ref fieldDto, stepFetchers, dto))); } catch (Exception ex) { Debug.WriteLine(ex.Message); throw; } } }
/// <summary> /// Updates field. /// </summary> /// <param name="data">The DTO object.</param> /// <param name="locDto">The loc dto.</param> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> public void UpdateFieldWithLocalization(FieldDto data, FieldLocalizationDto locDto) { if (data == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "data")); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; const string CommandText = @" UPDATE [dbo].[Fields] SET [FieldTypeId] = @p_FieldTypeId ,[IsRemoved] = @p_IsRemoved ,[LastModifiedOn] = @p_LastModifiedOn ,[SectionId] = @p_SectionId ,[Width] = @p_Width ,[RowSpan] = @p_RowSpan ,[ShowInList] = @p_ShowInList ,[IncludeInFilter] = @p_IncludeInFilter ,[UseInGlobalSearch] = @p_useInGlobalSearch ,[HideFromDetails] = @p_HideFromDetails ,[SystemName] = @p_SystemName ,[Position] = @p_Position ,[CopyOnSchedule] = @p_CopyOnSchedule ,[DeepCopy] = @p_DeepCopy ,[Guid] = @p_Guid ,[SearchPosition] = @p_SearchPosition ,[SearchWidth] = @p_SearchWidth ,[AllowLocalizedData] = @p_AllowLocalizedData WHERE [Id] = @p_Id"; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_Id", data.Id); command.Parameters.AddWithValue("@p_Name", data.Name); command.Parameters.AddWithValue("@p_SystemName", data.SystemName); command.Parameters.AddWithValue("@p_FieldTypeId", data.FieldTypeId); command.Parameters.AddWithValue("@p_IsRemoved", false); command.Parameters.AddWithValue("@p_LastModifiedOn", DateTime.Now); command.Parameters.AddWithValue("@p_Width", data.Width); command.Parameters.AddWithValue("@p_RowSpan", data.RowSpan); command.Parameters.AddWithValue("@p_ShowInList", data.ShowInList); command.Parameters.AddWithValue("@p_IncludeInFilter", data.IncludeInFilter); command.Parameters.AddWithValue("@p_useInGlobalSearch", data.UseInGlobalSearch); command.Parameters.AddWithValue("@p_HideFromDetails", data.HideFromDetails); command.Parameters.AddWithValue("@p_Position", data.Position); command.Parameters.AddWithValue("@p_CopyOnSchedule", data.CopyFieldValueOnCopyItem); command.Parameters.AddWithValue("@p_DeepCopy", data.DeepCopy); command.Parameters.AddWithValue("@p_Guid", data.Guid); command.Parameters.AddWithValue("@p_SearchPosition", data.SearchPosition); command.Parameters.AddWithValue("@p_SearchWidth", data.SearchWidth); command.Parameters.AddWithValue("@p_AllowLocalizedData", data.AllowLocalizedData); if (data.SectionId == null) { command.Parameters.AddWithValue("@p_SectionId", DBNull.Value); } else { command.Parameters.AddWithValue("@p_SectionId", data.SectionId); } command.ExecuteNonQuery(); } } UpdateFieldLocalization(locDto); }
/// <summary> /// Inserts field. /// </summary> /// <param name="dto">The DTO object.</param> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> /// <exception cref="System.Data.DBConcurrencyException">Stale data indicator.</exception> public void InsertField(FieldDto dto) { if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; const string CommandText = @" INSERT INTO [dbo].[Fields] ( [Name] ,[FieldTypeId] ,[IsRemoved] ,[LastModifiedOn] ,[SectionId] ,[Width] ,[RowSpan] ,[ShowInList] ,[IncludeInFilter] ,[UseInGlobalSearch] ,[HideFromDetails] ,[SystemName] ,[Position] ,[CopyOnSchedule] ,[DeepCopy] ,[Guid] ,[SearchPosition] ,[SearchWidth] ,[AllowLocalizedData] ) VALUES ( @p_Name ,@p_FieldTypeId ,@p_IsRemoved ,@p_LastModifiedOn ,@p_SectionId ,@p_Width ,@p_RowSpan ,@p_showInList ,@p_includeInFilter ,@p_useInGlobalSearch ,@p_hideFromDetails ,@p_SystemName ,@p_Position ,@p_CopyOnSchedule ,@p_DeepCopy ,@p_Guid ,@p_SearchPosition ,@p_SearchWidth ,@p_AllowLocalizedData ); --DECLARE @Identity AS INT SET @p_id = SCOPE_IDENTITY()"; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_Name", dto.Name); command.Parameters.AddWithValue("@p_SystemName", dto.SystemName); command.Parameters.AddWithValue("@p_FieldTypeId", dto.FieldTypeId); command.Parameters.AddWithValue("@p_IsRemoved", false); command.Parameters.AddWithValue("@p_Position", dto.Position); command.Parameters.AddWithValue("@p_LastModifiedOn", DateTime.Now); command.Parameters.AddWithValue("@p_SectionId", dto.SectionId); command.Parameters.AddWithValue("@p_Width", dto.Width); command.Parameters.AddWithValue("@p_RowSpan", dto.RowSpan); command.Parameters.AddWithValue("@p_showInList", dto.ShowInList); command.Parameters.AddWithValue("@p_CopyOnSchedule", dto.CopyFieldValueOnCopyItem); command.Parameters.AddWithValue("@p_DeepCopy", dto.DeepCopy); command.Parameters.AddWithValue("@p_includeInFilter", dto.IncludeInFilter); command.Parameters.AddWithValue("@p_useInGlobalSearch", dto.UseInGlobalSearch); command.Parameters.AddWithValue("@p_hideFromDetails", dto.HideFromDetails); command.Parameters.AddWithValue("@p_Guid", dto.Guid); command.Parameters.AddWithValue("@p_SearchPosition", dto.SearchPosition); command.Parameters.AddWithValue("@p_SearchWidth", dto.SearchWidth); command.Parameters.AddWithValue("@p_AllowLocalizedData", dto.AllowLocalizedData); var idParam = new SqlParameter("@p_id", SqlDbType.Int, 0, "Id") { Direction = ParameterDirection.Output }; command.Parameters.Add(idParam); var rowsAffetcted = command.ExecuteNonQuery(); if (rowsAffetcted == 0) { throw new DBConcurrencyException(Resources.StaleDataException); } dto.Id = (int)idParam.Value; } } }
private List<FieldDto> LoadFieldValues(SyncItem syncItem) { var fields = new List<FieldDto>(); foreach (var field in syncItem.SharedFields) { var fieldDto = new FieldDto {Id = Guid.Parse(field.FieldID), Value = field.FieldValue}; fields.Add(fieldDto); } foreach (var version in syncItem.Versions) { foreach (var field in version.Fields) { var fieldDto = new FieldDto {Id = Guid.Parse(field.FieldID), Value = field.FieldValue, Language = version.Language, Version = int.Parse(version.Version)}; fields.Add(fieldDto); } } return fields; }
public BookingPage(FieldDto fieldDto, string storeName) { InitializeComponent(); BindingContext = _viewModel = new BookingViewModel(fieldDto, storeName); }
/// <summary> /// Reads fields. /// </summary> /// <param name="process">The process.</param> /// <param name="sr">The reader.</param> private void ReadFields(ProcessEditDto process, SafeDataReader sr) { sr.NextResult(); int? sectionId = null; SectionDto section = null; var times = new List<double>(); while (sr.Read()) { var start = DateTime.Now; var fieldDto = new FieldDto { Id = sr.GetInt32(0), Name = sr.GetSafeString(1, string.Empty).Replace(@"""", "''"), FieldTypeId = sr.GetInt32(2), SectionId = sr.GetInt32(3), Width = sr.GetDouble(4), RowSpan = sr.GetInt(5), ShowInList = sr.GetBoolean(6), IncludeInFilter = sr.GetBoolean(7), HideFromDetails = sr.GetBoolean(8), SystemName = sr.GetString(9), Position = sr.GetInt32(10), CopyFieldValueOnCopyItem = sr.GetBool(11), DeepCopy = sr.GetBool(12), Guid = sr.GetGuid(13), SearchPosition = sr.GetInt(14), SearchWidth = sr.GetInt(15), IsBase = sr.GetBoolean(16), UseInGlobalSearch = sr.GetBoolean(19), PublishedCopyId = sr.GetNullableInt(21), AllowLocalizedData = sr.GetBoolean("AllowLocalizedData") }; if (fieldDto.SectionId != sectionId || section == null) { section = process.Sections.First(s => s.Id == fieldDto.SectionId); sectionId = fieldDto.SectionId; } fieldDto.FieldTypeInfo = new FieldTypeDto { Id = fieldDto.FieldTypeId, Name = sr.GetString(17), DataType = sr.GetString(18), CanBeRequired = sr.GetBoolean(20) }; section.FieldList.Add(fieldDto); times.Add((DateTime.Now - start).TotalMilliseconds); } Profiler.Profile(() => this.ReadFieldEditors(process, sr)); }
public void UpdateFieldDto(FieldDto fieldDto) { var field = Mapper.Map <Field>(fieldDto); UpdateField(field); }