Esempio n. 1
0
        public async Task <int> DeletePropertyCheckListAsync(PropertyCheckListModel model)
        {
            var property = new PropertyCheckList {
                PropertyCheckListId = model.PropertyCheckListId
            };

            using (var dataService = DataServiceFactory.CreateDataService())
            {
                return(await dataService.DeletePropertyCheckListAsync(property));
            }
        }
Esempio n. 2
0
        public async Task <int> AddPropertyCheckListAsync(PropertyCheckListModel model)
        {
            using (var dataService = DataServiceFactory.CreateDataService())
            {
                var property = new PropertyCheckList();
                if (property != null)
                {
                    UpdatePropertyCheckListFromModel(property, model);
                    property.PropertyGuid = Guid.NewGuid();
                    var propertyID = await dataService.AddPropertyCheckListAsync(property);

                    // model.Merge(await GetPropertyCheckListAsync(dataService, propertyID));
                    return(propertyID);
                }
                return(0);
            }
        }
Esempio n. 3
0
        private void UpdatePropertyCheckListFromModel(PropertyCheckList target, PropertyCheckListModel source)
        {
            target.PropertyCheckListId   = source.PropertyCheckListId;
            target.PropertyGuid          = source.PropertyGuid;
            target.PropertyName          = source.PropertyName;
            target.TalukId               = Convert.ToInt32(source.TalukId);
            target.HobliId               = Convert.ToInt32(source.HobliId);
            target.VillageId             = Convert.ToInt32(source.VillageId);
            target.DocumentTypeId        = Convert.ToInt32(source.DocumentTypeId);
            target.PropertyTypeId        = Convert.ToInt32(source.PropertyTypeId);
            target.SurveyNo              = source.SurveyNo;
            target.PropertyGMapLink      = source.PropertyGMapLink;
            target.LandAreaInputAcres    = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInputAcres) ? "0" : source.LandAreaInputAcres);
            target.LandAreaInputGuntas   = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInputGuntas) ? "0" : source.LandAreaInputGuntas);
            target.LandAreaInputAanas    = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInputAanas) ? "0" : source.LandAreaInputAanas);
            target.LandAreaInAcres       = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInAcres) ? "0" : source.LandAreaInAcres);
            target.LandAreaInGuntas      = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInGuntas) ? "0" : source.LandAreaInGuntas);
            target.LandAreaInSqMts       = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInSqMts) ? "0" : source.LandAreaInSqMts);
            target.LandAreaInSqft        = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInSqft) ? "0" : source.LandAreaInSqft);
            target.AKarabAreaInputAcres  = Convert.ToDecimal(string.IsNullOrEmpty(source.AKarabAreaInputAcres) ? "0" : source.AKarabAreaInputAcres);
            target.AKarabAreaInputGuntas = Convert.ToDecimal(string.IsNullOrEmpty(source.AKarabAreaInputGuntas) ? "0" : source.AKarabAreaInputGuntas);
            target.AKarabAreaInputAanas  = Convert.ToDecimal(string.IsNullOrEmpty(source.AKarabAreaInputAanas) ? "0" : source.AKarabAreaInputAanas);
            target.AKarabAreaInAcres     = Convert.ToDecimal(string.IsNullOrEmpty(source.AKarabAreaInAcres) ? "0" : source.AKarabAreaInAcres);
            target.AKarabAreaInGuntas    = Convert.ToDecimal(string.IsNullOrEmpty(source.AKarabAreaInGuntas) ? "0" : source.AKarabAreaInGuntas);
            target.AKarabAreaInSqMts     = Convert.ToDecimal(string.IsNullOrEmpty(source.AKarabAreaInSqft) ? "0" : source.AKarabAreaInSqft);
            target.AKarabAreaInSqft      = Convert.ToDecimal(string.IsNullOrEmpty(source.LandAreaInputAcres) ? "0" : source.LandAreaInputAcres);
            target.BKarabAreaInputAcres  = Convert.ToDecimal(string.IsNullOrEmpty(source.BKarabAreaInputAcres) ? "0" : source.BKarabAreaInputAcres);
            target.BKarabAreaInputGuntas = Convert.ToDecimal(string.IsNullOrEmpty(source.BKarabAreaInputGuntas) ? "0" : source.BKarabAreaInputGuntas);
            target.BKarabAreaInputAanas  = Convert.ToDecimal(string.IsNullOrEmpty(source.BKarabAreaInputAanas) ? "0" : source.BKarabAreaInputAanas);
            target.BKarabAreaInAcres     = Convert.ToDecimal(string.IsNullOrEmpty(source.BKarabAreaInAcres) ? "0" : source.BKarabAreaInAcres);
            target.BKarabAreaInGuntas    = Convert.ToDecimal(string.IsNullOrEmpty(source.BKarabAreaInGuntas) ? "0" : source.BKarabAreaInGuntas);
            target.BKarabAreaInSqMts     = Convert.ToDecimal(string.IsNullOrEmpty(source.BKarabAreaInSqMts) ? "0" : source.BKarabAreaInSqMts);
            target.BKarabAreaInSqft      = Convert.ToDecimal(string.IsNullOrEmpty(source.BKarabAreaInSqft) ? "0" : source.BKarabAreaInSqft);
            target.CompanyID             = Convert.ToInt32(source.CompanyID);
            target.PropertyDescription   = source.PropertyDescription;
            target.CheckListMaster       = source.CheckListMaster;

            //if (source.PropertyCheckListDocuments != null && source.PropertyCheckListDocuments.Count > 0)
            //{
            //    List<PropertyCheckListDocuments> docList = new List<PropertyCheckListDocuments>();
            //    foreach (var obj in source.PropertyCheckListDocuments)
            //    {
            //        var doc = new PropertyCheckListDocuments();
            //        UpdateDocumentFromModel(doc, obj);
            //        docList.Add(doc);
            //    }
            //    target.PropertyCheckListDocuments = docList;
            //}
            if (source.CheckListOfProperties != null && source.CheckListOfProperties.Count > 0)
            {
                List <CheckListOfProperty> checkList = new List <CheckListOfProperty>();
                foreach (var obj in source.CheckListOfProperties)
                {
                    var doc = new CheckListOfProperty();
                    UpdateCheckListFromModel(doc, obj);
                    checkList.Add(doc);
                }
                target.CheckListOfProperties = checkList;
            }

            if (source.PropertyCheckListVendors != null && source.PropertyCheckListVendors.Count > 0)
            {
                List <PropertyCheckListVendor> vendors = new List <PropertyCheckListVendor>();
                foreach (var obj in source.PropertyCheckListVendors)
                {
                    var doc = new PropertyCheckListVendor();
                    UpdateVendorFromModel(doc, obj);
                    vendors.Add(doc);
                }
                target.PropertyCheckListVendors = vendors;
            }
        }
Esempio n. 4
0
        static public async Task <PropertyCheckListModel> CreatePropertyCheckListModelWithDocsAsync(PropertyCheckList source)
        {
            var model = new PropertyCheckListModel()
            {
                PropertyCheckListId   = source.PropertyCheckListId,
                PropertyGuid          = source.PropertyGuid,
                PropertyName          = source.PropertyName,
                TalukId               = source.TalukId.ToString(),
                HobliId               = source.HobliId.ToString(),
                VillageId             = source.VillageId.ToString(),
                DocumentTypeId        = source.DocumentTypeId.ToString(),
                PropertyTypeId        = source.PropertyTypeId.ToString(),
                SurveyNo              = source.SurveyNo,
                PropertyGMapLink      = source.PropertyGMapLink,
                LandAreaInputAcres    = source.LandAreaInputAcres.ToString(),
                LandAreaInputGuntas   = source.LandAreaInputGuntas.ToString(),
                LandAreaInputAanas    = source.LandAreaInputAanas.ToString(),
                LandAreaInAcres       = source.LandAreaInAcres.ToString(),
                LandAreaInGuntas      = source.LandAreaInGuntas.ToString(),
                LandAreaInSqMts       = source.LandAreaInSqMts.ToString(),
                LandAreaInSqft        = source.LandAreaInSqft.ToString(),
                AKarabAreaInputAcres  = source.AKarabAreaInputAcres.ToString(),
                AKarabAreaInputGuntas = source.AKarabAreaInputGuntas.ToString(),
                AKarabAreaInputAanas  = source.AKarabAreaInputAanas.ToString(),
                AKarabAreaInAcres     = source.AKarabAreaInAcres.ToString(),
                AKarabAreaInGuntas    = source.AKarabAreaInGuntas.ToString(),
                AKarabAreaInSqMts     = source.AKarabAreaInSqMts.ToString(),
                AKarabAreaInSqft      = source.AKarabAreaInSqft.ToString(),
                BKarabAreaInputAcres  = source.BKarabAreaInputAcres.ToString(),
                BKarabAreaInputGuntas = source.BKarabAreaInputGuntas.ToString(),
                BKarabAreaInputAanas  = source.BKarabAreaInputAanas.ToString(),
                BKarabAreaInAcres     = source.BKarabAreaInAcres.ToString(),
                BKarabAreaInGuntas    = source.BKarabAreaInGuntas.ToString(),
                BKarabAreaInSqMts     = source.BKarabAreaInSqMts.ToString(),
                BKarabAreaInSqft      = source.BKarabAreaInSqft.ToString(),
                CompanyID             = source.CompanyID.ToString(),
                CompanyName           = source.CompanyName,
                VillageName           = source.VillageName,
                PropertyDescription   = source.PropertyDescription,
                CheckListMaster       = source.CheckListMaster,
                TotalArea             = source.TotalArea
            };

            //if (source.PropertyCheckListDocuments != null && source.PropertyCheckListDocuments.Count > 0)
            //{
            //    var docList = new ObservableCollection<PropertyCheckListDocumentsModel>();
            //    foreach (var obj in source.PropertyCheckListDocuments)
            //    {
            //        docList.Add(new PropertyCheckListDocumentsModel
            //        {
            //            PropertyCheckListBlobId = obj.PropertyCheckListBlobId,
            //            guid = obj.PropertyGuid,
            //            ImageBytes = obj.FileBlob,
            //            FileName = obj.FileName,
            //            ContentType = obj.FileType,
            //            FileCategoryId = obj.FileCategoryId,
            //            UploadTime = obj.UploadTime,
            //            DueDate = obj.DueDate,
            //            ActualCompletionDate = obj.ActualCompletionDate,
            //            Remarks = obj.Remarks
            //        });
            //    }
            //    model.PropertyCheckListDocuments =docList;
            //}

            if (source.CheckListOfProperties != null && source.CheckListOfProperties.Count > 0)
            {
                var checkList = new ObservableCollection <CheckListOfPropertyModel>();
                foreach (var obj in source.CheckListOfProperties)
                {
                    var checkItem = new CheckListOfPropertyModel
                    {
                        CheckListPropertyId = obj.CheckListPropertyId,
                        PropertyCheckListId = obj.PropertyCheckListId,
                        CheckListId         = obj.CheckListId,
                        Mandatory           = obj.Mandatory,
                        Name = obj.Name
                    };
                    var docList = new ObservableCollection <PropertyCheckListDocumentsModel>();
                    foreach (var doc in obj.Documents)
                    {
                        docList.Add(new PropertyCheckListDocumentsModel
                        {
                            PropertyCheckListBlobId = doc.PropertyCheckListBlobId,
                            CheckListPropertyId     = doc.CheckListPropertyId,
                            guid                 = doc.PropertyGuid,
                            ImageBytes           = doc.FileBlob,
                            FileName             = doc.FileName,
                            ContentType          = doc.FileType,
                            FileCategoryId       = doc.FileCategoryId,
                            UploadTime           = doc.UploadTime,
                            DueDate              = doc.DueDate,
                            ActualCompletionDate = doc.ActualCompletionDate,
                            Remarks              = doc.Remarks
                        });
                    }
                    checkItem.Documents = docList;

                    checkList.Add(checkItem);
                }
                model.CheckListOfProperties = checkList;
            }

            if (source.PropertyCheckListVendors != null && source.PropertyCheckListVendors.Count > 0)
            {
                var vendors = new ObservableCollection <PropertyCheckListVendorModel>();
                foreach (var obj in source.PropertyCheckListVendors)
                {
                    vendors.Add(new PropertyCheckListVendorModel
                    {
                        VendorId            = obj.VendorId,
                        VendorName          = obj.VendorName,
                        PropertyCheckListId = obj.PropertyCheckListId,
                        CheckListVendorId   = obj.CheckListVendorId,
                        IsGroup             = obj.IsGroup,
                        IsPrimaryVendor     = obj.IsPrimaryVendor
                    });
                }
                model.PropertyCheckListVendors = vendors;
            }

            return(model);
        }
Esempio n. 5
0
        static public async Task <PropertyCheckListModel> CreatePropertyCheckListModelAsync(PropertyCheckList source, bool includeAllFields)
        {
            var model = new PropertyCheckListModel()
            {
                PropertyCheckListId   = source.PropertyCheckListId,
                PropertyGuid          = source.PropertyGuid,
                PropertyName          = source.PropertyName,
                TalukId               = source.TalukId.ToString(),
                HobliId               = source.HobliId.ToString(),
                VillageId             = source.VillageId.ToString(),
                DocumentTypeId        = source.DocumentTypeId.ToString(),
                PropertyTypeId        = source.PropertyTypeId.ToString(),
                SurveyNo              = source.SurveyNo,
                PropertyGMapLink      = source.PropertyGMapLink,
                LandAreaInputAcres    = source.LandAreaInputAcres.ToString(),
                LandAreaInputGuntas   = source.LandAreaInputGuntas.ToString(),
                LandAreaInputAanas    = source.LandAreaInputAanas.ToString(),
                LandAreaInAcres       = source.LandAreaInAcres.ToString(),
                LandAreaInGuntas      = source.LandAreaInGuntas.ToString(),
                LandAreaInSqMts       = source.LandAreaInSqMts.ToString(),
                LandAreaInSqft        = source.LandAreaInSqft.ToString(),
                AKarabAreaInputAcres  = source.AKarabAreaInputAcres.ToString(),
                AKarabAreaInputGuntas = source.AKarabAreaInputGuntas.ToString(),
                AKarabAreaInputAanas  = source.AKarabAreaInputAanas.ToString(),
                AKarabAreaInAcres     = source.AKarabAreaInAcres.ToString(),
                AKarabAreaInGuntas    = source.AKarabAreaInGuntas.ToString(),
                AKarabAreaInSqMts     = source.AKarabAreaInSqMts.ToString(),
                AKarabAreaInSqft      = source.AKarabAreaInSqft.ToString(),
                BKarabAreaInputAcres  = source.BKarabAreaInputAcres.ToString(),
                BKarabAreaInputGuntas = source.BKarabAreaInputGuntas.ToString(),
                BKarabAreaInputAanas  = source.BKarabAreaInputAanas.ToString(),
                BKarabAreaInAcres     = source.BKarabAreaInAcres.ToString(),
                BKarabAreaInGuntas    = source.BKarabAreaInGuntas.ToString(),
                BKarabAreaInSqMts     = source.BKarabAreaInSqMts.ToString(),
                BKarabAreaInSqft      = source.BKarabAreaInSqft.ToString(),
                CompanyID             = source.CompanyID.ToString(),
                CompanyName           = source.CompanyName,
                VillageName           = source.VillageName,
                PropertyDescription   = source.PropertyDescription,
                CheckListMaster       = source.CheckListMaster,
                Remarks               = source.Remarks,
                Status    = source.Status,
                TotalArea = source.TotalArea
            };
            var area           = model.TotalArea.Split('-');
            var calculatedArea = LandBankManagement.AreaConvertor.ConvertArea(Convert.ToDecimal(area[0]), Convert.ToDecimal(area[1]), Convert.ToDecimal(area[2]));

            model.TotalArea = calculatedArea.Acres + " - " + calculatedArea.Guntas + " - " + calculatedArea.Anas;


            return(model);
        }
 public async Task <int> DeletePropertyCheckListAsync(PropertyCheckList model)
 {
     _dataSource.PropertyCheckList.Remove(model);
     return(await _dataSource.SaveChangesAsync());
 }
        public async Task <int> UpdatePropertyCheckListAsync(PropertyCheckList model)
        {
            try
            {
                //ICollection<PropertyCheckListDocuments> docs = model.PropertyCheckListDocuments;
                ICollection <PropertyCheckListVendor> vendors   = model.PropertyCheckListVendors;
                ICollection <CheckListOfProperty>     checklist = model.CheckListOfProperties;
                _dataSource.Entry(model).State = EntityState.Modified;
                await _dataSource.SaveChangesAsync();

                int res = model.PropertyCheckListId;
                //if (docs != null)
                //{
                //    foreach (var doc in docs)
                //    {
                //        if (doc.PropertyCheckListBlobId == 0)
                //        {
                //            doc.PropertyGuid = model.PropertyGuid;
                //            _dataSource.PropertyCheckListDocuments.Add(doc);
                //        }
                //    }
                //}
                //await _dataSource.SaveChangesAsync();
                if (vendors != null)
                {
                    foreach (var vendor in vendors)
                    {
                        if (vendor.CheckListVendorId == 0)
                        {
                            vendor.PropertyCheckListId = res;
                            _dataSource.PropertyCheckListVendor.Add(vendor);
                        }
                        else
                        {
                            _dataSource.PropertyCheckListVendor.Update(vendor);
                        }
                    }
                }
                await _dataSource.SaveChangesAsync();

                if (checklist != null)
                {
                    foreach (var check in checklist)
                    {
                        check.PropertyCheckListId = res;
                        if (check.CheckListPropertyId == 0)
                        {
                            _dataSource.CheckListOfProperty.Add(check);
                        }
                        else if (check.Delete)
                        {
                            var item = _dataSource.CheckListOfProperty.Where(x => x.CheckListPropertyId == check.CheckListPropertyId).FirstOrDefault();
                            _dataSource.CheckListOfProperty.Remove(item);
                        }
                        else
                        {
                            var item = _dataSource.CheckListOfProperty.Where(x => x.CheckListPropertyId == check.CheckListPropertyId).FirstOrDefault();
                            item.Mandatory = check.Mandatory;
                            _dataSource.Entry(item).State = EntityState.Modified;
                        }

                        var docs = check.Documents;
                        if (docs != null)
                        {
                            foreach (var doc in docs)
                            {
                                if (doc.PropertyCheckListBlobId == 0)
                                {
                                    doc.CheckListPropertyId = check.CheckListPropertyId;
                                    doc.PropertyGuid        = model.PropertyGuid;
                                    _dataSource.PropertyCheckListDocuments.Add(doc);
                                }
                            }
                        }
                    }
                }

                await _dataSource.SaveChangesAsync();

                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <int> AddPropertyCheckListAsync(PropertyCheckList model)
        {
            if (model == null)
            {
                return(0);
            }
            try
            {
                // ICollection<PropertyCheckListDocuments> docs = model.PropertyCheckListDocuments;
                ICollection <PropertyCheckListVendor> vendors   = model.PropertyCheckListVendors;
                ICollection <CheckListOfProperty>     checklist = model.CheckListOfProperties;

                var entity = new PropertyCheckList()
                {
                    PropertyGuid          = model.PropertyGuid,
                    PropertyName          = model.PropertyName,
                    TalukId               = model.TalukId,
                    HobliId               = model.HobliId,
                    VillageId             = model.VillageId,
                    DocumentTypeId        = model.DocumentTypeId,
                    PropertyTypeId        = model.PropertyTypeId,
                    SurveyNo              = model.SurveyNo,
                    PropertyGMapLink      = model.PropertyGMapLink,
                    LandAreaInputAcres    = model.LandAreaInputAcres,
                    LandAreaInputGuntas   = model.LandAreaInputGuntas,
                    LandAreaInputAanas    = model.LandAreaInputAanas,
                    LandAreaInAcres       = model.LandAreaInAcres,
                    LandAreaInGuntas      = model.LandAreaInGuntas,
                    LandAreaInSqMts       = model.LandAreaInSqMts,
                    LandAreaInSqft        = model.LandAreaInSqft,
                    AKarabAreaInputAcres  = model.AKarabAreaInputAcres,
                    AKarabAreaInputGuntas = model.AKarabAreaInputGuntas,
                    AKarabAreaInputAanas  = model.AKarabAreaInputAanas,
                    AKarabAreaInAcres     = model.AKarabAreaInAcres,
                    AKarabAreaInGuntas    = model.AKarabAreaInGuntas,
                    AKarabAreaInSqMts     = model.AKarabAreaInSqMts,
                    AKarabAreaInSqft      = model.AKarabAreaInSqft,
                    BKarabAreaInputAcres  = model.BKarabAreaInputAcres,
                    BKarabAreaInputGuntas = model.BKarabAreaInputGuntas,
                    BKarabAreaInputAanas  = model.BKarabAreaInputAanas,
                    BKarabAreaInAcres     = model.BKarabAreaInAcres,
                    BKarabAreaInGuntas    = model.BKarabAreaInGuntas,
                    BKarabAreaInSqMts     = model.BKarabAreaInSqMts,
                    BKarabAreaInSqft      = model.BKarabAreaInSqft,
                    CompanyID             = model.CompanyID,
                    CheckListMaster       = model.CheckListMaster,
                    PropertyDescription   = model.PropertyDescription
                };
                _dataSource.Entry(entity).State = EntityState.Added;
                await _dataSource.SaveChangesAsync();

                int res = entity.PropertyCheckListId;


                if (vendors != null)
                {
                    foreach (var vendor in vendors)
                    {
                        if (vendor.CheckListVendorId == 0)
                        {
                            vendor.PropertyCheckListId = res;
                            _dataSource.PropertyCheckListVendor.Add(vendor);
                        }
                    }
                }
                await _dataSource.SaveChangesAsync();

                if (checklist != null)
                {
                    foreach (var check in checklist)
                    {
                        if (check.CheckListPropertyId == 0)
                        {
                            check.PropertyCheckListId = res;
                            _dataSource.CheckListOfProperty.Add(check);
                        }
                        await _dataSource.SaveChangesAsync();

                        var docs = check.Documents;
                        if (docs != null)
                        {
                            foreach (var doc in docs)
                            {
                                if (doc.PropertyCheckListBlobId == 0)
                                {
                                    doc.CheckListPropertyId = check.CheckListPropertyId;
                                    doc.PropertyGuid        = model.PropertyGuid;
                                    _dataSource.PropertyCheckListDocuments.Add(doc);
                                }
                            }
                        }
                    }
                }
                await _dataSource.SaveChangesAsync();

                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }