public async Task <PropertyModel> AddPropertyAsync(PropertyModel model, ICollection <PropertyDocumentTypeModel> propDocType, ICollection <ImagePickerResult> docs) { using (var dataService = DataServiceFactory.CreateDataService()) { var property = new Property(); List <PropertyDocumentType> propertyDocumentTypeList = new List <PropertyDocumentType>(); var propertyDoc = propDocType.First(); var propertyDocumentType = new PropertyDocumentType(); UpdatePropertyDocumentTypeFromModel(propertyDocumentType, propertyDoc); if (propertyDoc.PropertyDocuments != null && propertyDoc.PropertyDocuments.Count > 0) { List <PropertyDocuments> docList = new List <PropertyDocuments>(); foreach (var obj in propertyDoc.PropertyDocuments) { var doc = new PropertyDocuments(); UpdateDocumentFromModel(doc, obj); docList.Add(doc); } propertyDocumentType.PropertyDocuments = docList; } propertyDocumentTypeList.Add(propertyDocumentType); property.PropertyDocumentType = propertyDocumentTypeList; UpdatePropertyFromModel(property, model); property.PropertyGuid = Guid.NewGuid(); property.GroupGuid = (model.GroupGuid == null || model.GroupGuid == Guid.Empty) ? Guid.NewGuid() : model.GroupGuid;// For Grouping property var propertyID = await dataService.AddPropertyAsync(property); model.Merge(await GetPropertyAsync(dataService, propertyID)); return(model); } }
public async Task <PropertyModel> UpdatePropertyAsync(PropertyModel model, ICollection <PropertyDocumentTypeModel> propDocType, ICollection <ImagePickerResult> docs) { using (var dataService = DataServiceFactory.CreateDataService()) { var property = new Property(); List <PropertyDocumentType> propertyDocumentTypeList = new List <PropertyDocumentType>(); foreach (var propertyDoc in propDocType) { var propertyDocumentType = new PropertyDocumentType(); UpdatePropertyDocumentTypeFromModel(propertyDocumentType, propertyDoc); if (propertyDoc.PropertyDocuments != null && propertyDoc.PropertyDocuments.Count > 0) { List <PropertyDocuments> docList = new List <PropertyDocuments>(); foreach (var obj in propertyDoc.PropertyDocuments) { var doc = new PropertyDocuments(); UpdateDocumentFromModel(doc, obj); docList.Add(doc); } propertyDocumentType.PropertyDocuments = docList; } propertyDocumentTypeList.Add(propertyDocumentType); } property.PropertyDocumentType = propertyDocumentTypeList; UpdatePropertyFromModel(property, model); await dataService.UpdatePropertyAsync(property); model.Merge(await GetPropertyAsync(dataService, property.PropertyId)); return(model); } }
public async Task <int> DeletePropertyDocumentAsync(ImagePickerResult documents) { using (var dataService = DataServiceFactory.CreateDataService()) { var doc = new PropertyDocuments(); UpdateDocumentFromModel(doc, documents); return(await dataService.DeletePropertyDocumentAsync(doc)); } }
private void UpdateDocumentFromModel(PropertyDocuments target, ImagePickerResult source) { target.PropertyBlobId = source.blobId; target.PropertyGuid = source.guid; target.FileBlob = source.ImageBytes; target.FileName = source.FileName; target.FileType = source.ContentType; target.FileCategoryId = source.FileCategoryId; target.UploadTime = DateTime.Now; target.PropertyDocumentTypeId = source.DocumentType; }
public Response Add(PropertyDocuments value) { Response response = new Response(); try { using (IDbConnection conn = GetConnection()) { conn.Insert(value); response.Status = true; response.Description = "Successful"; } } catch (Exception ex) { response.Status = false; response.Description = ex.Message; } return(response); }
public async Task <int> SaveDocuments(ICollection <ImagePickerResult> docs, Guid propertyGuid, int propertyDocumentTypeId) { if (docs != null && docs.Count > 0) { using (var dataService = DataServiceFactory.CreateDataService()) { List <PropertyDocuments> docList = new List <PropertyDocuments>(); foreach (var obj in docs) { var doc = new PropertyDocuments(); UpdateDocumentFromModel(doc, obj); doc.PropertyGuid = propertyGuid; doc.PropertyDocumentTypeId = propertyDocumentTypeId; docList.Add(doc); } return(await dataService.UploadPropertyDocumentsAsync(docList)); } } return(0); }
public async Task <int> DeletePropertyDocumentAsync(PropertyDocuments documents) { _dataSource.PropertyDocuments.Remove(documents); return(await _dataSource.SaveChangesAsync()); }
public Response Put([FromBody] PropertyDocuments value) { return(repo.Update(value)); }
public Response Post([FromBody] PropertyDocuments value) { return(repo.Add(value)); }