Beispiel #1
0
 public static IEnumerable <TenantJobRequest> GetOwnerMarketJobs(Login login)
 {
     using (var db = new KeysEntities())
     {
         return(db.TenantJobRequest.Where(x => x.JobStatusId == 1 && x.OwnerId == login.Id));
     }
 }
 public static Login GetLoginById(int id)
 {
     using (var db = new KeysEntities())
     {
         return(db.Login.FirstOrDefault(x => x.Id == id));
     }
 }
 public static bool IsServSupplier(Login login)
 {
     using (var db = new KeysEntities())
     {
         return(login == null ? false : db.LoginRole.FirstOrDefault(x => x.PersonId == login.Id && x.IsActive && x.RoleId == 6) == null ? false : true);
     }
 }
 public static Login GetAwaitingActivateUserByEmail(string email, string token)
 {
     using (var db = new KeysEntities())
     {
         return(db.Login.Where(x => x.UserName == email && x.EmailConfirmationToken == token).FirstOrDefault());
     }
 }
 public static ServiceResponseResult ActivateLogin(int loginId)
 {
     using (var db = new KeysEntities())
     {
         var login = db.Login.Where(x => x.Id == loginId).FirstOrDefault();
         if (login == null)
         {
             return(new ServiceResponseResult {
                 IsSuccess = false
             });
         }
         try
         {
             login.EmailConfirmed = true;
             login.IsActive       = true;
             db.SaveChanges();
             return(new ServiceResponseResult {
                 IsSuccess = true
             });
         }
         catch (Exception ex)
         {
             return(new ServiceResponseResult {
                 IsSuccess = false
             });
         }
     }
 }
 public static Login GetLoginByEmail(string email)
 {
     using (var db = new KeysEntities())
     {
         return(db.Login.FirstOrDefault(x => x.Email == email && x.IsActive));
     }
 }
 public static Person GetPersonByLoginId(int loginId)
 {
     using (var db = new KeysEntities())
     {
         return(db.Person.FirstOrDefault(x => x.Id == loginId));
     }
 }
        public static ServiceResponseResult DeleteRentallApllication(int rentalApplicationId)
        {
            var result = new ServiceResponseResult {
                IsSuccess = false
            };

            using (var db = new KeysEntities())
            {
                var deleteRentallApllication = db.RentalApplication.Where(x => x.Id == rentalApplicationId).First();
                if (deleteRentallApllication == null)
                {
                    var errorMsg = "Cannot locate the Rental application";
                    result.ErrorMessage = errorMsg;
                    return(result);
                }
                else
                {
                    deleteRentallApllication.IsActive = false;
                };
                try
                {
                    db.SaveChanges();
                    return(new ServiceResponseResult {
                        IsSuccess = true
                    });
                }
                catch (Exception ex)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false, ErrorMessage = _error
                    });
                }
            }
        }
 public static IEnumerable <RentalListing> GetRentalProperties(string searchString, string sortOrder)
 {
     using (var db = new KeysEntities())
     {
         return(db.RentalListing.Include("Property").Include("RentalListingMedia").Include("Property.Address").Include("Property.PropertyType").Include("Property.TargetRentType").Include("Property.PropertyMedia").Where(x => x.IsActive == true).ToList());
     }
 }
Beispiel #10
0
 public static ServiceResponseResult AddPropertyOwnerMarketJob(JobMarketModel marketJob, Login login, HttpFileCollectionBase files = null, string serverPath = null)
 {
     using (var db = new KeysEntities())
     {
         var newMarketJob = new TenantJobRequest();
         newMarketJob.JobDescription = marketJob.JobDescription;
         newMarketJob.PropertyId     = marketJob.PropertyId;
         newMarketJob.JobStatusId    = 1; // should be OPEN
         newMarketJob.CreatedBy      = login.Email;
         newMarketJob.CreatedOn      = DateTime.UtcNow;
         newMarketJob.UpdatedOn      = DateTime.UtcNow;
         newMarketJob.UpdatedBy      = login.Email;
         newMarketJob.MaxBudget      = marketJob.MaxBudget;
         newMarketJob.OwnerId        = login.Id;
         newMarketJob.Title          = marketJob.Title;
         db.TenantJobRequest.Add(newMarketJob);
         try
         {
             db.SaveChanges();
             var mediaResult = AddMarketJobMedia(files, newMarketJob.Id, serverPath);
             return(mediaResult.IsSuccess ? new ServiceResponseResult {
                 IsSuccess = true
             }
                                         : new ServiceResponseResult {
                 IsSuccess = false, ErrorMessage = mediaResult.ErrorMessage
             });
         }
         catch (Exception)
         {
             return(new ServiceResponseResult {
                 IsSuccess = false, ErrorMessage = _error
             });
         }
     }
 }
Beispiel #11
0
        public static JobMarketModel GetMarketJobById(int id)
        {
            using (var db = new KeysEntities())
            {
                var marketJob = db.TenantJobRequest.FirstOrDefault(x => x.Id == id);
                if (marketJob == null)
                {
                    return(null);
                }
                var j = new JobMarketModel
                {
                    Id      = marketJob.Id,
                    Title   = marketJob.Title,
                    Address = new AddressViewModel
                    {
                        AddressId = marketJob.Property.Address.AddressId,
                        CountryId = marketJob.Property.Address.CountryId,
                        Number    = marketJob.Property.Address.Number.Replace(" ", ""),
                        Street    = marketJob.Property.Address.Street.Trim(),
                        City      = marketJob.Property.Address.City.Trim(),
                        Suburb    = marketJob.Property.Address.Suburb.Trim() ?? "",
                        PostCode  = marketJob.Property.Address.PostCode.Replace(" ", ""),
                    },
                    JobDescription = marketJob.JobDescription,
                    MaxBudget      = marketJob.MaxBudget,
                    PostedDate     = marketJob.CreatedOn,
                    MediaFiles     = marketJob.TenantJobRequestMedia.Select(y => new MediaModel {
                        NewFileName = y.NewFileName, OldFileName = y.OldFileName, Id = y.Id
                    }).ToList(),
                };

                return(j);
            }
        }
Beispiel #12
0
 public static IEnumerable <RequestStatus> GetAllRequestStatus()
 {
     using (var db = new KeysEntities())
     {
         return(db.RequestStatus.ToList());
     }
 }
Beispiel #13
0
 public static IQueryable <JobQuote> GetJobQuotesByMarketJoaddbId(int marketJobId)
 {
     using (var db = new KeysEntities())
     {
         return(db.JobQuote.Where(x => x.JobRequestId == marketJobId));
     }
 }
Beispiel #14
0
        public static ServiceResponseResult QuoteViewed(int quoteId)
        {
            using (var db = new KeysEntities())
            {
                var quote = db.JobQuote.FirstOrDefault(x => x.Id == quoteId);
                if (quote == null)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false, ErrorMessage = "Can note find quote"
                    });
                }

                if (quote.IsViewed ?? false)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false
                    });
                }
                quote.IsViewed = true;
                try
                {
                    db.SaveChanges();
                    return(new ServiceResponseResult {
                        IsSuccess = true
                    });
                }
                catch (Exception ex)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false, ErrorMessage = _error
                    });
                }
            }
        }
        public static ServiceResponseResult ResetPasswordToken(ForgotPasswordViewModel model, string newToken)
        {
            using (var db = new KeysEntities())
            {
                try
                {
                    var user = db.Login.FirstOrDefault(x => x.Email == model.Email);
                    if (user == null)
                    {
                        return(new ServiceResponseResult {
                            IsSuccess = false, ErrorMessage = "This Email - ID is not registered in the system.Please register!"
                        });
                    }

                    user.ResetPasswordToken           = newToken;
                    user.ResetPasswordTokenExpiryDate = DateTime.Now.AddHours(2);
                    db.SaveChanges();
                    return(new ServiceResponseResult {
                        IsSuccess = true
                    });
                }
                catch (Exception)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false, ErrorMessage = _serverError
                    });
                }
            }
        }
 public static IEnumerable <RequestType> GetRequestTypes()
 {
     using (var db = new KeysEntities())
     {
         return(db.RequestType.ToList());
     }
 }
 public static bool SendActivationEmailToUser(int userId, string tokenConfirmationUrl)
 {
     using (var db = new KeysEntities())
     {
         var           user = db.Login.FirstOrDefault(x => x.Id == userId);
         StringBuilder sb   = new StringBuilder();
         sb.AppendLine("Hi User,<br/>");
         sb.Append("<br/><table style='border-color:#666' cellpadding='10' width='100%'>");
         sb.Append("<tbody><tr style='background:#3c8dbc'>");
         sb.Append("<td>Account activation link for Property Community User</td></tr><tr>");
         sb.Append("<td> Welcome User To complete the signup process please click on the activation link ");
         sb.Append($"<a href='{tokenConfirmationUrl}'>Activate Now</a>");
         sb.AppendLine("</td></tr></tbody></table>");
         sb.Append("<br/><br/>Regards,<br>Software Team");
         try
         {
             MailMessage Mail = new MailMessage();
             Mail.To.Add(user.Email);
             Mail.Subject    = ("Account Email Verification");
             Mail.Body       = (sb.ToString());
             Mail.IsBodyHtml = true;
             EmailService.SendAsync(Mail);
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
 public static RentalApplication GetRentalApplicationById(int id)
 {
     using (var db = new KeysEntities())
     {
         return(db.RentalApplication.FirstOrDefault(x => x.Id == id));
     }
 }
 public static Login GetExistingLogin(string email)
 {
     using (var db = new KeysEntities())
     {
         return(db.Login.FirstOrDefault(x => x.Email == email));
     }
 }
Beispiel #20
0
 public static Tenant GetTenantByLogin(Login login)
 {
     using (var db = new KeysEntities())
     {
         return(login == null ? null : db.Tenant.FirstOrDefault(x => x.Id == login.Id));
     }
 }
 public static bool CheckIfUserExist(string userName)
 {
     using (var db = new KeysEntities())
     {
         return(db.Login.Any(x => x.UserName == userName));
     }
 }
Beispiel #22
0
 public static bool IsTenantInProperty(Login tenant, int propertyId)
 {
     using (var db = new KeysEntities())
     {
         return(db.TenantProperty.Where(x => x.TenantId == tenant.Id && x.PropertyId == propertyId).Any());
     }
 }
 public static Login GetAwaitingActivateUserById(int id, string token)
 {
     using (var db = new KeysEntities())
     {
         return(db.Login.Where(x => x.Id == id && x.EmailConfirmationToken == token).FirstOrDefault());
     }
 }
Beispiel #24
0
 public static ServiceResponseResult DeclineRequest(RequestModel model, Login login)
 {
     using (var db = new KeysEntities())
     {
         var request = db.PropertyRequest.Where(x => x.Id == model.Id).First();
         var rId     = request.RequestStatusId;
         if (rId == 2 || rId == 4 || rId == 5)
         {
             return(new ServiceResponseResult {
                 IsSuccess = true, ErrorMessage = "Can not update request!"
             });
         }
         if (request != null)
         {
             request.Reason          = model.Reason;
             request.RequestStatusId = 5;
             request.UpdatedBy       = login.Id;
             request.UpdatedOn       = DateTime.UtcNow;
         }
         ;
         try
         {
             db.SaveChanges();
             return(new ServiceResponseResult {
                 IsSuccess = true
             });
         }
         catch (Exception)
         {
             return(new ServiceResponseResult {
                 IsSuccess = true, ErrorMessage = _error
             });
         }
     }
 }
 public static ServiceResponseResult ResetActivate(int loginId, string token)
 {
     using (var db = new KeysEntities())
     {
         var emailConfirmToken = Guid.NewGuid();
         var loginAgain        = AccountService.GetAwaitingActivateUserById(loginId, token);
         if (loginAgain != null)
         {
             try
             {
                 loginAgain.EmailConfirmationToken           = emailConfirmToken.ToString();
                 loginAgain.EmailConfirmationTokenExpiryDate = DateTime.Now.AddHours(2).ToUniversalTime();  // FOR TESTING PURPOSE VALIDITY SET FOR 2 HRS
                 db.Login.Attach(loginAgain);
                 db.Entry(loginAgain).State = EntityState.Modified;
                 db.SaveChanges();
                 return(new ServiceResponseResult {
                     IsSuccess = true, NewObject = loginAgain.EmailConfirmationToken
                 });
             }
             catch (Exception e)
             {
                 return(new ServiceResponseResult {
                     IsSuccess = false
                 });
             }
         }
         else
         {
             return(new ServiceResponseResult {
                 IsSuccess = false, ErrorMessage = "OOPS....!!!!You have clicked on the old activation link Or Your Account details are not correct"
             });
         }
     }
 }
Beispiel #26
0
 public static ServiceResponseResult AccepLandlordRequest(int requestId)
 {
     using (var db = new KeysEntities())
     {
         var request = db.PropertyRequest.Where(x => x.Id == requestId).FirstOrDefault();
         var rId     = request.RequestStatusId;
         if (rId == 2 || rId == 4 || rId == 5)
         {
             return(new ServiceResponseResult {
                 IsSuccess = true, ErrorMessage = "Can not update request!"
             });
         }
         request.RequestStatusId = 2;
         try
         {
             db.SaveChanges();
             return(new ServiceResponseResult {
                 IsSuccess = true
             });
         }
         catch (Exception ex)
         {
             return(new ServiceResponseResult {
                 IsSuccess = true, ErrorMessage = _error
             });
         }
     }
 }
 public static IEnumerable <Role> GetAllRoles()
 {
     using (var db = new KeysEntities())
     {
         return(db.Role.ToList());
     }
 }
        // GET: Personal/Watchlist
        public ActionResult Index(WatchlistDisplayModel model)
        {
            var login     = AccountService.GetLoginByEmail(User.Identity.Name);
            var userRoles = AccountService.GetUserRolesbyEmail(User.Identity.Name);

            if (userRoles.Contains(5))
            {
                model.ItemType     = model.ItemType ?? ItemType.RentalListing;
                model.IsUserTenant = true;
            }
            if (userRoles.Contains(6))
            {
                model.IsUserServiceSupply = true;
                model.ItemType            = model.ItemType ?? ItemType.MarketJob;
            }

            using (var db = new KeysEntities())
            {
                if (model.ItemType == ItemType.RentalListing || model.ItemType == 0)
                {
                    model.ItemType = ItemType.RentalListing;
                    model          = GetRentalWatchlist(model, login);
                }
                else if (model.ItemType == ItemType.MarketJob)
                {
                    model = GetMarketJobWatchlist(model, login);
                }
                var tenant = TenantService.GetTenantByEmail(User.Identity.Name);
                model.IsUserTenant            = userRoles.Contains(5);
                model.IsTenantProfileComplete = tenant?.IsCompletedPersonalProfile ?? false;
                model.IsProfileComplete       = CompanyService.IsProfileComplete(login);

                return(View(model));
            }
        }
 public static bool SavePersonMedia(List <MediaModel> mediaData, int personId)
 {
     try
     {
         using (var db = new KeysEntities())
         {
             foreach (var item in mediaData)
             {
                 db.PersonMedia.Add(new PersonMedia()
                 {
                     IsActive    = true,
                     NewFilename = item.NewFileName,
                     OldFilename = item.OldFileName,
                     PersonId    = personId
                 });
             }
             db.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #30
0
        public ActionResult Delete(int id)
        {
            using (var db = new KeysEntities())
            {
                var delPerson = db.Person.Find(id);
                // Moved this into the Else statement. Dmitry
                //var delPersonLogin = db.Login.Find(delPerson.LoginId);

                // Bug #1185
                // Changed AND to an OR. Dmitry
                if (delPerson == null || delPerson.IsActive == false)
                {
                    return(Json(new { Result = "norecord", Message = "Cannot find this record !" }));
                }

                else
                {
                    var delPersonLogin = db.Login.Find(delPerson.Id);

                    if (delPersonLogin.UserName == User.Identity.Name)
                    {
                        return(Json(new { Result = "ownrecord", Message = "Admin can not delete their record !" }));
                    }
                    else
                    {
                        delPerson.IsActive      = false;
                        delPersonLogin.IsActive = false;
                        db.SaveChanges();
                        return(Json(new { Result = "success", Message = "Record deleted successfully" }));
                    }
                }
            }
        }