public ActionResult Insert(ReferralDTO referral) { var referralDb = new Referral(); Mapper.FromReferralDTO(referral, referralDb); ReferralService.Insert(referralDb); return(this.CamelCaseJson(new { Success = true })); }
[HttpPost("applications/{appId}/referrals")] // should this potentially just be "Referrals"? public async Task <ActionResult <ReferralDTO> > PostReferral(ReferralDTO referralDTO) { Referral referral = DTOToReferral(referralDTO); _context.Referrals.Add(referral); await _context.SaveChangesAsync(); return(CreatedAtAction("PostReferral", new { AppliationId = referral.ApplicationId, ReferralId = referral.ReferralId }, referralDTO)); }
private static Referral DTOToReferral(ReferralDTO rDTO) => new Referral { ApplicationId = rDTO.ApplicationId, Application = null, ReferralId = rDTO.ReferralId, Name = rDTO.Name, Email = rDTO.Email, Position = rDTO.Position, Company = rDTO.Company, Phone = rDTO.Phone };
public ActionResult Save(ReferralDTO referral) { var referralDb = ReferralService.GetReferral(referral.Id); if (referralDb == null) { return(Json(new { success = false })); } Mapper.FromReferralDTO(referral, referralDb); ReferralService.Save(referralDb); return(this.CamelCaseJson(new { Success = true })); }
public async Task <ReferralDTO> ViewReferralContactDetails(string refernceid) { try { ReferralDTO ReferralDTO = new ReferralDTO(); ReferralDTO = await obj.GetReferraldeatils(Con, refernceid); return(ReferralDTO); } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } }
public async Task <string> AddReferralCode(ReferralDTO referralDTO) { referralDTO.ReferralCode = CommonHelper.GenereateRandonAlphaNumeric(); bool exists; try { //if person already has a code if (String.IsNullOrEmpty(referralDTO.Email) || referralDTO.Email == "*****@*****.**") { exists = await _repository.ExistAsync(x => x.PhoneNumber == referralDTO.PhoneNumber); } else { exists = await _repository.ExistAsync(x => x.ReferralCode == referralDTO.ReferralCode || x.Email == referralDTO.Email || x.PhoneNumber == referralDTO.PhoneNumber); } //if referral code already exists if (await _repository.ExistAsync(x => x.ReferralCode == referralDTO.ReferralCode)) { referralDTO.ReferralCode = CommonHelper.GenereateRandonAlphaNumeric(); } } catch (Exception) { exists = true; } if (!exists) { var entity = new Referral { Email = referralDTO.Email, PhoneNumber = referralDTO.PhoneNumber, ReferralCode = referralDTO.ReferralCode, UserType = referralDTO.UserType }; _repository.Insert(entity); _unitOfWork.SaveChanges(); return(referralDTO.ReferralCode); } else { return(null); } }
public async Task <IActionResult> PatchReferral(long appId, long refId, ReferralDTO referralDTO) { Referral referral = DTOToReferral(referralDTO); if (appId != referralDTO.ApplicationId || refId != referralDTO.ReferralId) { return(BadRequest("One of the query params does not match the body params")); } User user = await userManager.FindByNameAsync(User.Identity.Name); IList <string> roles = await userManager.GetRolesAsync(user); if (!roles.Contains(UserRoles.Admin)) { var query = from queryReferral in _context.Referrals join application in _context.Applications on queryReferral.ApplicationId equals application.ApplicationId join jobPost in _context.JobPosts on application.JobId equals jobPost.JobPostId join recruiter in _context.Recruiters on user.Id equals recruiter.UserId where jobPost.CompanyId == recruiter.CompanyId && queryReferral.ApplicationId == referral.ApplicationId && queryReferral.ReferralId == referral.ReferralId select queryReferral; if (!await query.AnyAsync()) { return(Unauthorized("Cannot modify the referral for that application")); } } _context.Entry(referral).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReferralExists(appId, refId)) { return(NotFound()); } else { throw; } } return(AcceptedAtAction("PatchReferral", new { ApplicationId = referral.ApplicationId, ReferralId = referral.ReferralId }, referralDTO)); }
public int AddReferral(ReferralDTO referral) { Model.Entity.Referral referralEntity = new Model.Entity.Referral(); referralEntity.ReferralID = getNewReferralId(); referralEntity.PostID = referral.PostID; referralEntity.Subject = referral.Subject; referralEntity.Message = referral.Message; referralEntity.CreatedBy = referral.CreatedBy; referralEntity.CreatedOn = DateTime.Now; _referralRepository.Add(referralEntity); _unitOfWork.Commit(); return(referralEntity.ReferralID); }
public int Add(ReferralDTO referral) { ApplicationUser applicationUser = RequestContext.GetLoggedInUser(); referral.CreatedBy = applicationUser.UserID; int referrralId = _referralService.AddReferral(referral); //Send referral request if (referrralId > 0) { this._emailService.SendAsyncMail(applicationUser.EmailAddress, referral.To, referral.Subject, referral.Message); } return(referrralId); }
public IActionResult SaveContactReferral([FromBody] ReferralDTO ReferralDTO) { try { if (obj.SaveContactReferral(Con, ReferralDTO)) { return(Ok(true)); } else { return(StatusCode((int)HttpStatusCode.NotModified)); } } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } }
public static ReferralDTO FromReferral(Referral referral) { var dto = new ReferralDTO { Id = referral.ID, DateCreated = referral.DateCreated, Status = MapStatus(referral.Status), StatusNotes = referral.StatusNotes, DismissalReasonId = referral.DismissalReasonID, DismissalReason = referral.DismissalNote, DismissalReasonNotes = referral.DismissalNoteExtended, FollowUp = referral.Followup, FollowUpDate = referral.FollowupDate, SourceTypeId = referral.SourceTypeID, SourceName = referral.SourceName, ReferrerNotes = referral.ReferrerNotes, AssignedStaffId = referral.AssignedStaffID, LastName = referral.LastName, FirstName = referral.FirstName, DateOfBirth = referral.DateOfBirth, PrimaryLanguage = referral.PrimaryLanguage, AreaOfConcern = referral.AreaOfConcern, ServicesRequested = referral.ServicesRequested, Email = referral.Email, Phone = referral.Phone, Address1 = referral.Address1, Address2 = referral.Address2, City = referral.City, State = referral.State, ZipCode = referral.ZipCode, CompanyName = referral.InsuranceCompanyName, MemberId = referral.InsuranceMemberID, PrimaryCardholderDateOfBirth = referral.InsurancePrimaryCardholderDOB, PrimaryCardholderName = referral.InsurancePrimaryCardholderName, CompanyProviderPhone = referral.InsuranceProviderPhone, BenefitCheck = referral.BenefitCheck, InsuranceStatus = referral.InsuranceStatus, IntakeStatus = referral.IntakeStatus, RxStatus = referral.RxStatus, InsuranceCardStatus = referral.InsuranceCardStatus, EvaluationStatus = referral.EvaluationStatus, PolicyBookStatus = referral.PolicyBookStatus, InsuranceCompanyId = referral.InsuranceCompanyID, FundingType = referral.FundingType, BenefitType = referral.BenefitType, CoPayAmount = referral.CoPayAmount, CoInsuranceAmount = referral.CoInsuranceAmount, DeductibleTotal = referral.DeductibleTotal, GuardianLastName = referral.GuardianLastName, GuardianFirstName = referral.GuardianFirstName, GuardianRelationshipId = referral.GuardianRelationshipID, GuardianEmail = referral.GuardianEmail, GuardianCellPhone = referral.GuardianCellPhone, GuardianHomePhone = referral.GuardianHomePhone, GuardianWorkPhone = referral.GuardianWorkPhone, GuardianNotes = referral.GuardianNotes, Guardian2FirstName = referral.Guardian2FirstName, Guardian2LastName = referral.Guardian2LastName, Guardian2Email = referral.Guardian2Email, Guardian2CellPhone = referral.Guardian2CellPhone, Guardian2HomePhone = referral.Guardian2HomePhone, Guardian2WorkPhone = referral.Guardian2WorkPhone, Guardian2RelationshipId = referral.Guardian2RelationshipID, Guardian2Notes = referral.Guardian2Notes, Guardian3FirstName = referral.Guardian3FirstName, Guardian3LastName = referral.Guardian3LastName, Guardian3RelationshipId = referral.Guardian3RelationshipID, Guardian3CellPhone = referral.Guardian3CellPhone, Guardian3HomePhone = referral.Guardian3HomePhone, Guardian3WorkPhone = referral.Guardian3WorkPhone, Guardian3Email = referral.Guardian3Email, Guardian3Notes = referral.Guardian3Notes, PhysicianName = referral.PhysicianName, PhysicianAddress = referral.PhysicianAddress, PhysicianEmail = referral.PhysicianEmail, PhysicianContact = referral.PhysicianContact, PhysicianFax = referral.PhysicianFax, PhysicianNotes = referral.PhysicianNotes, PhysicianPhone = referral.PhysicianPhone }; if (!referral.GuardianRelationshipID.HasValue && !string.IsNullOrEmpty(referral.GuardianRelationship)) { if (Enum.TryParse(referral.GuardianRelationship, true, out GuardianRelationship relationship)) { dto.GuardianRelationshipId = (int)relationship; } } dto.Checklist = referral.Checklist.Select(m => FromChecklist(m)); return(dto); }
public static void FromReferralDTO(ReferralDTO referral, Referral referralDb) { referralDb.Status = MapStatus(referral.Status); referralDb.DismissalReasonID = referral.DismissalReasonId; referralDb.DismissalNote = referral.DismissalReason; referralDb.DismissalNoteExtended = referral.DismissalReasonNotes; referralDb.Followup = referral.FollowUp; referralDb.FollowupDate = referral.FollowUpDate; referralDb.SourceTypeID = referral.SourceTypeId; referralDb.SourceName = referral.SourceName; referralDb.ReferrerNotes = referral.ReferrerNotes; referralDb.AssignedStaffID = referral.AssignedStaffId; referralDb.LastName = referral.LastName; referralDb.FirstName = referral.FirstName; referralDb.DateOfBirth = referral.DateOfBirth; referralDb.PrimaryLanguage = referral.PrimaryLanguage; referralDb.AreaOfConcern = referral.AreaOfConcern; referralDb.ServicesRequested = referral.ServicesRequested; referralDb.StatusNotes = referral.StatusNotes; referralDb.GuardianLastName = referral.GuardianLastName; referralDb.GuardianFirstName = referral.GuardianFirstName; referralDb.GuardianRelationshipID = referral.GuardianRelationshipId; referralDb.GuardianEmail = referral.GuardianEmail; referralDb.GuardianCellPhone = referral.GuardianCellPhone; referralDb.GuardianHomePhone = referral.GuardianHomePhone; referralDb.GuardianWorkPhone = referral.GuardianWorkPhone; referralDb.GuardianNotes = referral.GuardianNotes; referralDb.Guardian2FirstName = referral.Guardian2FirstName; referralDb.Guardian2LastName = referral.Guardian2LastName; referralDb.Guardian2Email = referral.Guardian2Email; referralDb.Guardian2CellPhone = referral.Guardian2CellPhone; referralDb.Guardian2HomePhone = referral.Guardian2HomePhone; referralDb.Guardian2WorkPhone = referral.Guardian2WorkPhone; referralDb.Guardian2RelationshipID = referral.Guardian2RelationshipId; referralDb.Guardian2Notes = referral.Guardian2Notes; referralDb.Guardian3FirstName = referral.Guardian3FirstName; referralDb.Guardian3LastName = referral.Guardian3LastName; referralDb.Guardian3RelationshipID = referral.Guardian3RelationshipId; referralDb.Guardian3CellPhone = referral.Guardian3CellPhone; referralDb.Guardian3HomePhone = referral.Guardian3HomePhone; referralDb.Guardian3WorkPhone = referral.Guardian3WorkPhone; referralDb.Guardian3Email = referral.Guardian3Email; referralDb.Guardian3Notes = referral.Guardian3Notes; referralDb.PhysicianName = referral.PhysicianName; referralDb.PhysicianAddress = referral.PhysicianAddress; referralDb.PhysicianEmail = referral.PhysicianEmail; referralDb.PhysicianContact = referral.PhysicianContact; referralDb.PhysicianFax = referral.PhysicianFax; referralDb.PhysicianNotes = referral.PhysicianNotes; referralDb.PhysicianPhone = referral.PhysicianPhone; referralDb.Email = referral.Email; referralDb.Phone = referral.Phone; referralDb.Address1 = referral.Address1; referralDb.Address2 = referral.Address2; referralDb.City = referral.City; referralDb.State = referral.State; referralDb.ZipCode = referral.ZipCode; referralDb.InsuranceCompanyName = referral.CompanyName; referralDb.InsuranceMemberID = referral.MemberId; referralDb.InsurancePrimaryCardholderDOB = referral.PrimaryCardholderDateOfBirth; referralDb.InsurancePrimaryCardholderName = referral.PrimaryCardholderName; referralDb.InsuranceProviderPhone = referral.CompanyProviderPhone; referralDb.BenefitCheck = referral.BenefitCheck; referralDb.InsuranceStatus = referral.InsuranceStatus; referralDb.IntakeStatus = referral.IntakeStatus; referralDb.RxStatus = referral.RxStatus; referralDb.InsuranceCardStatus = referral.InsuranceCardStatus; referralDb.EvaluationStatus = referral.EvaluationStatus; referralDb.PolicyBookStatus = referral.PolicyBookStatus; referralDb.InsuranceCompanyID = referral.InsuranceCompanyId; referralDb.FundingType = referral.FundingType; referralDb.BenefitType = referral.BenefitType; referralDb.CoPayAmount = referral.CoPayAmount; referralDb.CoInsuranceAmount = referral.CoInsuranceAmount; referralDb.DeductibleTotal = referral.DeductibleTotal; if (referral.Checklist != null) { foreach (var cl in referral.Checklist) { var clDb = referralDb.Checklist.SingleOrDefault(m => m.ID == cl.Id); if (clDb != null) { clDb.IsComplete = cl.IsComplete; } } } }