public async Task <int> UpdatePropertyMergeAsync(PropertyMergeModel model) { using (var dataService = DataServiceFactory.CreateDataService()) { var propertyMerge = new PropertyMerge(); UpdatePropertyMergeFromModel(propertyMerge, model); if (model.propertyMergeLists != null && model.propertyMergeLists.Count > 0) { var list = new List <PropertyMergeList>(); foreach (var obj in model.propertyMergeLists) { if (obj.PropertyMergeListId > 0) { continue; } var propertyMergelist = new PropertyMergeList(); UpdatePropertyMergeListFromModel(propertyMergelist, obj); propertyMergelist.PropertyMergeListId = 0; propertyMergelist.PropertyMergeGuid = propertyMerge.PropertyMergeGuid; list.Add(propertyMergelist); } propertyMerge.propertyMergeLists = list; } await dataService.UpdatePropertyMergeAsync(propertyMerge); model.Merge(await GetPropertyMergeAsync(dataService, propertyMerge.PropertyMergeId)); return(0); } }
public async Task <int> DeletePropertyMergeAsync(PropertyMerge model) { try { var dealPrepared = await _dataSource.Deal.Where(x => x.PropertyMergeId == model.PropertyMergeId).FirstOrDefaultAsync(); if (dealPrepared != null) { return(0); } var entities = _dataSource.PropertyMergeList.Where(x => x.PropertyMergeGuid == model.PropertyMergeGuid); if (entities != null) { _dataSource.PropertyMergeList.RemoveRange(entities); await _dataSource.SaveChangesAsync(); } _dataSource.PropertyMerge.Remove(model); return(await _dataSource.SaveChangesAsync()); } catch (Exception ex) { throw ex; } }
public async Task <int> DeletePropertyMergeAsync(PropertyMergeModel model) { var propertyMerge = new PropertyMerge { PropertyMergeId = model.PropertyMergeId, PropertyMergeGuid = model.PropertyMergeGuid }; using (var dataService = DataServiceFactory.CreateDataService()) { return(await dataService.DeletePropertyMergeAsync(propertyMerge)); } }
static public async Task <PropertyMergeModel> CreatePropertyMergeModelAsync(PropertyMerge source, bool includeAllFields) { var model = new PropertyMergeModel() { PropertyMergeId = source.PropertyMergeId, PropertyMergeGuid = source.PropertyMergeGuid, PropertyMergeDealName = source.PropertyMergeDealName, MergedTotalArea = source.MergedTotalArea, MergedSaleValue1 = source.MergedSaleValue1.ToString("N"), MergedSaleValue2 = source.MergedSaleValue2.ToString("N"), MergedAmountPaid1 = source.MergedAmountPaid1.ToString("N"), MergedAmountPaid2 = source.MergedAmountPaid2.ToString("N"), MergedBalancePayable1 = source.MergedBalancePayable1, MergedBalancePayable2 = source.MergedBalancePayable2, ForProposal = source.ForProposal, FormattedTotalArea = source.FormattedTotalArea, IsSold = source.IsSold }; if (source.propertyMergeLists != null && source.propertyMergeLists.Count > 0) { model.propertyMergeLists = new ObservableCollection <PropertyMergeListModel>(); foreach (var obj in source.propertyMergeLists) { model.propertyMergeLists.Add(new PropertyMergeListModel { PropertyMergeListId = obj.PropertyMergeListId, PropertyMergeGuid = obj.PropertyMergeGuid, PropertyDocumentTypeId = obj.PropertyDocumentTypeId, DocumentTypeName = obj.DocumentTypeName, PropertyGuid = obj.PropertyGuid, PropertyName = obj.PropertyName, Party = obj.Party, Village = obj.Village, SurveyNo = obj.SurveyNo, LandArea = obj.LandArea, AKarab = obj.AKarab, BKarab = obj.BKarab, SaleValue1 = string.IsNullOrEmpty(obj.SaleValue1) ? "" : Convert.ToDecimal(obj.SaleValue1).ToString("N"), SaleValue2 = string.IsNullOrEmpty(obj.SaleValue2) ? "" : Convert.ToDecimal(obj.SaleValue2).ToString("N"), Amount1 = string.IsNullOrEmpty(obj.Amount1) ? "" : Convert.ToDecimal(obj.Amount1).ToString("N"), Amount2 = string.IsNullOrEmpty(obj.Amount2) ? "" : Convert.ToDecimal(obj.Amount2).ToString("N"), Expense = string.IsNullOrEmpty(obj.Expense) ? "" : Convert.ToDecimal(obj.Expense).ToString("N"), Balance1 = string.IsNullOrEmpty(obj.Balance1) ? "" : Convert.ToDecimal(obj.Balance1).ToString("N"), Balance2 = string.IsNullOrEmpty(obj.Balance2) ? "" : Convert.ToDecimal(obj.Balance2).ToString("N"), TotalArea = obj.TotalArea, CompanyId = obj.companyId, propertyId = obj.propertyId }); } } return(model); }
private void UpdatePropertyMergeFromModel(PropertyMerge target, PropertyMergeModel source) { target.PropertyMergeId = source.PropertyMergeId; target.PropertyMergeGuid = source.PropertyMergeGuid; target.PropertyMergeDealName = source.PropertyMergeDealName; target.MergedTotalArea = source.MergedTotalArea; target.MergedSaleValue1 = source.MergedSaleValue1; target.MergedSaleValue2 = source.MergedSaleValue2; target.MergedAmountPaid1 = source.MergedAmountPaid1; target.MergedAmountPaid2 = source.MergedAmountPaid2; target.MergedBalancePayable1 = source.MergedBalancePayable1; target.MergedBalancePayable2 = source.MergedBalancePayable2; target.ForProposal = source.ForProposal; target.FormattedTotalArea = source.FormattedTotalArea; }
private void UpdatePropertyMergeFromModel(PropertyMerge target, PropertyMergeModel source) { target.PropertyMergeId = source.PropertyMergeId; target.PropertyMergeGuid = source.PropertyMergeGuid; target.PropertyMergeDealName = source.PropertyMergeDealName; target.MergedTotalArea = source.MergedTotalArea; target.MergedSaleValue1 = string.IsNullOrEmpty(source.MergedSaleValue1)?0:Convert.ToDecimal(source.MergedSaleValue1); target.MergedSaleValue2 = string.IsNullOrEmpty(source.MergedSaleValue2) ? 0 : Convert.ToDecimal(source.MergedSaleValue2); target.MergedAmountPaid1 = string.IsNullOrEmpty(source.MergedAmountPaid1) ? 0 : Convert.ToDecimal(source.MergedAmountPaid1); target.MergedAmountPaid2 = string.IsNullOrEmpty(source.MergedAmountPaid2) ? 0 : Convert.ToDecimal(source.MergedAmountPaid2); target.MergedBalancePayable1 = source.MergedBalancePayable1; target.MergedBalancePayable2 = source.MergedBalancePayable2; target.ForProposal = source.ForProposal; target.FormattedTotalArea = source.FormattedTotalArea; }
public async Task <int> UpdatePropertyMergeAsync(PropertyMerge model) { try { _dataSource.Entry(model).State = EntityState.Modified; int res = await _dataSource.SaveChangesAsync(); foreach (var pay in model.propertyMergeLists) { _dataSource.Entry(pay).State = EntityState.Added; } await _dataSource.SaveChangesAsync(); return(res); } catch (Exception ex) { throw ex; } }
public async Task <int> AddPropertyMergeAsync(PropertyMerge model) { if (model == null) { return(0); } try { var entity = new PropertyMerge() { PropertyMergeGuid = model.PropertyMergeGuid, PropertyMergeDealName = model.PropertyMergeDealName, MergedTotalArea = model.MergedTotalArea, MergedSaleValue1 = model.MergedSaleValue1, MergedSaleValue2 = model.MergedSaleValue2, MergedAmountPaid1 = model.MergedAmountPaid1, MergedAmountPaid2 = model.MergedAmountPaid2, MergedBalancePayable1 = model.MergedBalancePayable1, MergedBalancePayable2 = model.MergedBalancePayable2, ForProposal = model.ForProposal, FormattedTotalArea = model.FormattedTotalArea }; _dataSource.Entry(entity).State = EntityState.Added; int res = await _dataSource.SaveChangesAsync(); foreach (var item in model.propertyMergeLists) { _dataSource.Entry(item).State = EntityState.Added; } await _dataSource.SaveChangesAsync(); return(entity.PropertyMergeId); } catch (Exception ex) { throw ex; } }