public Task <FlatOwnerFamily> Create(FlatOwnerFamily flatOwnerFamily)
        {
            var taskResult = Task.Run(() =>
            {
                using (var context = new DbContext())
                {
                    if (flatOwnerFamily.FlatOwner != null)
                    {
                        flatOwnerFamily.FlatOwnerId = flatOwnerFamily.FlatOwner.Id;
                        flatOwnerFamily.FlatOwner   = null;
                    }
                    if (flatOwnerFamily.Gender != null)
                    {
                        flatOwnerFamily.GenderId = flatOwnerFamily.Gender.Id;
                        flatOwnerFamily.Gender   = null;
                    }

                    if (flatOwnerFamily.Relationship != null)
                    {
                        flatOwnerFamily.RelationshipId = flatOwnerFamily.Relationship.Id;
                        flatOwnerFamily.Relationship   = null;
                    }

                    context.FlatOwnerFamilies.Add(flatOwnerFamily);
                    context.SaveChanges();
                    return(flatOwnerFamily);
                }
            });

            return(taskResult);
        }
Ejemplo n.º 2
0
        public Task RegisterTenantFamily(FlatOwnerFamily family, long?societyId, long?complexId, ApplicationUser currentUser)
        {
            return(Task.Run(async() =>
            {
                //Role Tenant Family = 9
                var familyRole = new ApplicationRole()
                {
                    Id = ProgramCommon.TenantFamily, Name = "Tenant Family"
                };
                var roles = new ApplicationRole[] { familyRole };

                IdentityResult result = await CreateLogin(ProgramCommon.GetFormattedUsername(family.Name), null, family.MobileNo, roles
                                                          , null, family.Name, family.MobileNo, bBlocked: false, bChangePass: true, isback: false, societyId: societyId,
                                                          complexId: complexId, currentUser: currentUser);
            }));
        }
        public Task Update(FlatOwnerFamily flatOwnerFamily)
        {
            var taskResult = Task.Run(() =>
            {
                using (var context = new DbContext())
                {
                    var existingRecord = context.FlatOwnerFamilies.FirstOrDefault(p => p.Id == flatOwnerFamily.Id);

                    if (existingRecord == null)
                    {
                        throw new Exception("Flatowner family detail not found");
                    }
                    if (flatOwnerFamily.FlatOwner != null)
                    {
                        flatOwnerFamily.FlatOwnerId = flatOwnerFamily.FlatOwner.Id;
                        flatOwnerFamily.FlatOwner   = null;
                    }
                    if (flatOwnerFamily.Gender != null)
                    {
                        flatOwnerFamily.GenderId = flatOwnerFamily.Gender.Id;
                        flatOwnerFamily.Gender   = null;
                    }

                    if (flatOwnerFamily.Relationship != null)
                    {
                        flatOwnerFamily.RelationshipId = flatOwnerFamily.Relationship.Id;
                        flatOwnerFamily.Relationship   = null;
                    }
                    existingRecord.Name           = flatOwnerFamily.Name;
                    existingRecord.AdminMember    = flatOwnerFamily.AdminMember;
                    existingRecord.ApproverMember = flatOwnerFamily.ApproverMember;
                    existingRecord.MobileNo       = flatOwnerFamily.MobileNo;
                    existingRecord.AadhaarCardNo  = flatOwnerFamily.AadhaarCardNo;
                    existingRecord.DateOfBirth    = flatOwnerFamily.DateOfBirth;
                    existingRecord.IsRejected     = false;

                    context.SaveChanges();
                }
            });

            return(taskResult);
        }
        public Task UpdateUserId(FlatOwnerFamily flatOwnerFamily, long userid)
        {
            var taskResult = Task.Run(() =>
            {
                using (var context = new DbContext())
                {
                    var existingRecord = context
                                         .FlatOwnerFamilies
                                         .FirstOrDefault(p => p.Id == flatOwnerFamily.Id);

                    if (existingRecord == null)
                    {
                        throw new Exception("Family detail not found");
                    }

                    existingRecord.UserId = userid;
                    context.SaveChanges();
                }
            });

            return(taskResult);
        }
Ejemplo n.º 5
0
 public Task Update(FlatOwnerFamily flatOwnerFamily)
 {
     return(_flatOwnerFamilyRepository.Update(flatOwnerFamily));
 }
Ejemplo n.º 6
0
 public Task <FlatOwnerFamily> Create(FlatOwnerFamily flatOwnerFamily)
 {
     return(_flatOwnerFamilyRepository.Create(flatOwnerFamily));
 }
Ejemplo n.º 7
0
        public Task <List <ReportFlatOwnersTenantsDetail> > UploadFlatOwnersFamily(List <ReportFlatOwnersTenantsDetail> families)
        {
            var taskResult = Task.Run(async() =>
            {
                using (var context = new DbContext())
                {
                    //validate
                    foreach (var item in families)
                    {
                        StringBuilder sb = new StringBuilder();

                        if (string.IsNullOrEmpty(item.Society))
                        {
                            sb.Append(",Society");
                        }

                        if (string.IsNullOrEmpty(item.Building))
                        {
                            sb.Append(",Building");
                        }

                        if (string.IsNullOrEmpty(item.Wing))
                        {
                            sb.Append(",Wing");
                        }

                        if (string.IsNullOrEmpty(item.Floor))
                        {
                            sb.Append(",Floor");
                        }

                        if (string.IsNullOrEmpty(item.Flat))
                        {
                            sb.Append(",Flat");
                        }

                        if (string.IsNullOrEmpty(item.Owner))
                        {
                            sb.Append(",Flat Owner");
                        }

                        if (string.IsNullOrEmpty(item.OwnerType))
                        {
                            sb.Append(",Flat Owner Type");
                        }

                        if (string.IsNullOrEmpty(item.Name))
                        {
                            sb.Append(",Name");
                        }
                        if (string.IsNullOrEmpty(item.Gender))
                        {
                            sb.Append(",Gender.");
                        }
                        if (string.IsNullOrEmpty(item.Relationship))
                        {
                            sb.Append(",Relationship");
                        }

                        if (sb.Length > 0)
                        {
                            sb.Append(" is/are missing.");
                            sb.Append("<br />");
                        }

                        var gender = context
                                     .MasterValues
                                     .FirstOrDefault(m => m.Type == (byte)EnMasterValueType.Gender && m.Text.Equals(item.Gender, StringComparison.InvariantCultureIgnoreCase));
                        if (gender == null)
                        {
                            sb.Append("Gender text not found in master.");
                            sb.Append("<br />");
                        }

                        var relationship = context
                                           .MasterValues
                                           .FirstOrDefault(m => m.Type == (byte)EnMasterValueType.Relationship && m.Text.Equals(item.Relationship, StringComparison.InvariantCultureIgnoreCase));
                        if (relationship == null)
                        {
                            sb.Append("Relationship text not found in master.");
                            sb.Append("<br />");
                        }

                        if (sb.Length > 0)
                        {
                            item.IsSuccess = false;
                            item.Message   = sb.ToString().Trim(',');
                            continue;
                        }

                        var flatowner = (from msf in context.MapsSocietiesToFacilities
                                         join f in context.Facilities on msf.FacilityId equals f.Id
                                         join flr in context.Floors on f.Id equals flr.FacilityId
                                         join fls in context.Flats on flr.Id equals fls.FloorId
                                         join mffo in context.MapsFlatToFlatOwner on fls.Id equals mffo.FlatId
                                         join fos in context.FlatOwners on mffo.FlatOwnerId equals fos.Id

                                         where msf.Society.Name.Equals(item.Society, StringComparison.InvariantCultureIgnoreCase) &&
                                         f.Name.Equals(item.Building, StringComparison.InvariantCultureIgnoreCase) &&
                                         f.Wing.Equals(item.Wing, StringComparison.InvariantCultureIgnoreCase) &&
                                         flr.Name.Equals(item.Floor, StringComparison.InvariantCultureIgnoreCase) &&
                                         fls.Name.Equals(item.Flat, StringComparison.InvariantCultureIgnoreCase) &&
                                         fos.Name.Equals(item.Owner, StringComparison.InvariantCultureIgnoreCase) &&
                                         mffo.FlatOwnerType == (item.OwnerType.Equals("Owner", StringComparison.InvariantCultureIgnoreCase) ? 1 : 2)

                                         select new
                        {
                            fo = fos
                        })
                                        .Select(f => f.fo)
                                        .FirstOrDefault();

                        if (flatowner == null)
                        {
                            item.IsSuccess = false;
                            item.Message   = string.Format("No flat found for {0}-{1}-{2}-{3}-{4}.", item.Society, item.Building, item.Wing, item.Floor, item.Flat);
                            continue;
                        }

                        var family = new FlatOwnerFamily()
                        {
                            Name           = item.Name,
                            MobileNo       = item.MobileNo,
                            AadhaarCardNo  = item.AadhaarCardNo,
                            DateOfBirth    = item.DateOfBirth,
                            GenderId       = gender.Id,
                            RelationshipId = relationship.Id,
                            FlatOwnerId    = flatowner.Id
                        };

                        try
                        {
                            await _flatOwnerFamilyRepository.Create(family);
                        }
                        catch (Exception ex)
                        {
                            item.IsSuccess = false;
                            item.Message   = ex.Message;
                            continue;
                        }

                        item.IsSuccess = true;
                        item.Message   = "Done";
                    }

                    return(families);
                }
            });

            return(taskResult);
        }