예제 #1
0
 public Turn GetLast2Turned(Associate associate)
 {
     return new PoolTurn
         {
             Id = 1,
             Name = "Ida a Piscina",
             Price = 10.00
         };
 }
예제 #2
0
 public Turn GetLast2Turned(Associate associate)
 {
     return new TenisTurn
     {
         Id = 1,
         Name = "Ida a quadra de Tênis",
         Price = 20.00
     };
 }
예제 #3
0
        public Item GetLast5BuyedItems(Associate associate)
        {
            //Should return the buyed items from this associate

            return new Item
                {
                    Id = 1,
                    Name = "Item 2",
                    Price = 12.00
                };
        }
예제 #4
0
 private Receive WaitingForConnected(IActorRef replyTo, Associate associate)
 {
     return message =>
     {
         if (message is Tcp.Connected)
         {
             var connected = message as Tcp.Connected;
             var handler = Context.ActorOf(Props.Create(() => new ConnectionAssociationActor(Sender)));
             Sender.Tell(new Tcp.Register(handler));
             replyTo.Tell(new ConnectionAssociationHandle(handler, connected.LocalAddress.ToAddress(Context.System), associate.RemoteAddress));
             UnbecomeStacked();
             Stash.Unstash();
             return true;
         }
         if (message is Tcp.CommandFailed)
         {
             //TODO: Handle
             return true;
         }
         return Queue(message);
     };
 }
예제 #5
0
 public void SaveUpdatedAssociate(Associate associate)
 {
     Associate momentaDBAssociate = associate;
     this.MomentaDb.SaveChanges();
 }
예제 #6
0
        private static bool DetermineIfAssociateAvailableFrom(int noticePeriod, int interval, Associate x)
        {
            // immediately available
            var currentlyAvailable = (byte?)AvailabilityTypeEnum.CurrentlyAvailable;

            if (x.AvailabilityTypeId == currentlyAvailable)
            {
                return(true);
            }

            // todo: permanently employee
            // todo: temporary/contract with notice
            return(false);
        }
예제 #7
0
        public Associate SearchAssociate(Associate associate)
        {
            Associate ObjAssociate = new Associate();

            return(ObjAssociate);
        }
예제 #8
0
        public void InsertAssociateToItris(Associate associate, string empId)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(empId));

            string title;
            string businessType;

            if (associate.PersonTitleId == 5)
            {
                title = associate.TitleOther;
            }
            else
            {
                title = this.MomentaDb.PersonTitles
                            .Where(t => t.PersonTitleId == associate.PersonTitleId)
                            .Select(t => t.Description)
                            .FirstOrDefault();
            }

            switch ((BusinessType?)associate.BusinessTypeID)
            {
                case BusinessType.ContractLtdCompany:
                    businessType = "L";
                    break;
                case BusinessType.Umbrella:
                    businessType = "U";
                    break;
                default:
                    businessType = null;
                    break;
            }

            string countyName = associate.OtherCounty;

            if (string.IsNullOrEmpty(countyName))
            {
                County county = this.MomentaDb.Counties.SingleOrDefault(c => c.ID == associate.CountyID);
                if (county != null)
                {
                    countyName = county.Name;
                }
            }

            // Personal Details
            this.ItrisDb.ip_AddNewApplicant(
                title: title,
                firstName: associate.FirstName,
                middleName: associate.MiddleName,
                lastName: associate.LastName,
                birthDate: associate.DateOfBirth,
                mobileTel: associate.MobilePhone,
                homeTel: associate.HomePhone,
                workTel: associate.WorkPhone,
                otherTel: associate.OtherPhone,
                address: string.Format("{0} {1} {2} {3} {4} {5}", associate.UnitNumber, associate.HouseName, associate.HouseNumber, associate.Street, associate.Town, countyName),
                postCode: associate.Postcode,
                eMail: associate.Email,
                oFlags: 8,
                workType: associate.AvailabilityTypeId,
                //// Field is mandatory but not used in Portal site.
                available: associate.AvailabilityTypeId != 1 ? associate.AvailableDate : null,
                //// set again by ip_SetAppAvailability anyway
                notice: associate.AvailabilityTypeId == 2 ? associate.NoticePeriod : 0,
                //// set again by ip_SetAppAvailability anyway
                skillsList: null,
                //// set again by ip_SetAppAvailability anyway
                empID: empId,
                tFlags: 32639,
                rate: null,
                salary: null,
                rateInt: null,
                retJobID: null,
                groupID: null,
                addToScan: null,
                typeID: null,
                nationID: null,
                fAOOf: null,
                wEBAddress: null,
                lTDCoName: null,
                mediaID: null,
                cVText: null,
                originalCVPath: null,
                statusID: null,
                addToEAAReg: null,
                profile: null,
                companyID: null,
                contactID: null,
                jobTitle: null,
                ownerID: null,
                holdDays: null,
                profileHTML: null);

            Applicant newApplicant =
                this.ItrisDb.Applicants.OrderByDescending(a => a.CREATED_ON).FirstOrDefault(
                    a => a.EMAIL == associate.Email);

            if (newApplicant == null)
            {
                throw new RecordNotFoundException(
                    string.Format("newApplicant with email {0}could not be retrieved", associate.Email));
            }

            string applicantId = newApplicant.APP_ID;

            // Set Visa stuff.
            Debug.Assert(associate.HasVisa != null, "associate.HasVisa != null");

            this.ItrisDb.ip_UpdatePersonalDetails(
                appID: applicantId,
                vISA_EXPIRY: associate.HasVisa.Value ? associate.VisaExpiry : null,
                visaType: associate.HasVisa.Value ? this.MomentaDb.VisaTypes.Where(v => v.ID == associate.VisaTypeId.Value).Select(v => v.Name).Single() : null,
                vISA_NO: associate.VisaNumber,
                nI_NUMBER: associate.NI,
                tAX_CODE: null,
                nI_CODE_LETTER: null,
                pASSPORT_NO: associate.PassportNumber,
                dAYS_PER_WEEK: null,
                iD_VERIFIED: null,
                vERIFIED_BY: null,
                vAT_REGISTERED: null,
                vAT_REG_NO: null,
                bUSINESS_TYPE: businessType,
                tRADE_NAME: null,
                tRADE_DESCRIPTION: null,
                tRADE_ADDRESS: null,
                tRADE_POST_CODE: null,
                cOMP_REG_NO: null,
                sTUDENT: null,
                bANK_NAME: null,
                bANK_ADDRESS: null,
                aCCOUNT_NO: null,
                sORT_CODE: null,
                aCCOUNT_NAME: null,
                bANKBUILD_REF: null,
                sWIFT_CODE: null,
                iBAN_NUMBER: null,
                eMP_ID: null,
                gENDER: null,
                mARITAL_STATUS: null,
                umbrellaCompanyID: null);

            this.ItrisDb.ip_SetAppAvailability(
                appID: applicantId,
                date: associate.AvailabilityTypeId != 1 ? associate.AvailableDate : null,
                nextCallDate: null,
                notice: associate.AvailabilityTypeId == 2 ? associate.NoticePeriod : 0,
                workType: associate.AvailabilityTypeId,
                noticeType: associate.AvailabilityTypeId == 2 ? associate.NoticeIntervalId : null);

            // Set Comments
            this.ItrisDb.ip_UpdateApplicantDetails(
                appID: applicantId,
                empID: empId,
                qComments: string.Empty,
                forceUpdate: false,
                tFlags: null,
                oFlags: null,
                deleted: null,
                lastContacted: null,
                eMail: null,
                homeTel: null,
                workTel: null,
                mobileTel: null,
                otherTel: null,
                address: null,
                postCode: null,
                wEBAddress: null,
                dOB: null,
                lastCV: null,
                lastTyped: null,
                typeID: null,
                ownerID: null,
                fAOOf: null,
                nationID: null,
                currentPosition: null);
            this.ItrisDb.SaveChanges();

            // Update associate.ITRISAppId
            Associate momentaDBAssociate = this.MomentaDb.Associates.Single(a => a.ID == associate.ID);
            momentaDBAssociate.ITRISAppId = applicantId;
            this.MomentaDb.SaveChanges();
        }
 public int DeleteAssociate(Associate inputAssociate)
 {
     return(this._associateRepo.DeleteAssociate(inputAssociate));
 }
예제 #10
0
        private static bool DetermineNoticeAvailability(int noticePeriod, int interval, Associate x, DateTime today)
        {
            // immediately available
            var currentlyAvailable = (byte?)AvailabilityTypeEnum.CurrentlyAvailable;
            if (x.AvailabilityTypeId == currentlyAvailable)
            {
                return true;
            }

            // on contract
            var onContract = (byte?)AssociateApprovalStatusEnum.OnContract;
            if (x.AssociateApprovalStatusId == onContract)
            {
                // associates on more than one contract are not available
                if (x.Individual.Count > 1)
                {
                    return false;
                }

                // todo: lookup the notice period from the requirement
                var associateNoticePeriod = x.NoticePeriod.Value * interval;

                var availableDate = x.AvailableDate.Value;

                var available = today.AddDays(associateNoticePeriod);

                return availableDate <= available;
            }

            // permanently employee
            var permanentlyEmployed = (byte?)AvailabilityTypeEnum.PermanentlyEmployed;
            if (x.AvailabilityTypeId == permanentlyEmployed)
            {
                if (x.NoticePeriod == null)
                {
                    return false;
                }

                var associateNoticePeriod = x.NoticePeriod.Value * interval;
                return associateNoticePeriod <= noticePeriod;
            }

            // temporary/contract with notice
            var withNotice = (byte?)AvailabilityTypeEnum.TemporaryContractWithNotice;
            if (x.AvailabilityTypeId == withNotice)
            {
                if (x.NoticePeriod == null || x.AvailableDate == null)
                {
                    return false;
                }

                var associateNoticePeriod = x.NoticePeriod.Value * interval;

                var availableDate = x.AvailableDate.Value;

                var available = today.AddDays(associateNoticePeriod);

                return availableDate <= available;
            }

            return false;
        }
예제 #11
0
        public ActionResult GetAssociate(int AssociateID)
        {
            Associate objA = new Associate(AssociateID);

            return(Json(objA));
        }
예제 #12
0
 public int AddAssociate(Associate inputAssociate)
 {
     return(this._associateRepo.AddAssociate(inputAssociate));
 }
예제 #13
0
        public Associate UpdateAssociate(Associate associate, Site sourceSite)
        {
            Associate originalAssociate = this.GetAssociate(associate.ID);

            // check if Company Name or VAT registration number has changed
            if (originalAssociate.VATRegistration != associate.VATRegistration ||
                originalAssociate.RegisteredCompanyName != associate.RegisteredCompanyName ||
                originalAssociate.VATRegistered != associate.VATRegistered)
            {
                // reset the self billing date to be invalid for the document
                associate.OptOutSelfBillingSignedDate = null;
            }

            // Not round tripped
            associate.CreatedDate = originalAssociate.CreatedDate;

            associate.ITRISAppId = originalAssociate.ITRISAppId;

            associate.ReferralSourceID = originalAssociate.ReferralSourceID;

            associate.AssociateApprovalStatusId = originalAssociate.AssociateApprovalStatusId;
            associate.DeclarationSignedDate = originalAssociate.DeclarationSignedDate;

            associate.HasBeenVatRegistered = originalAssociate.HasBeenVatRegistered || (associate.VATRegistered == true);

            bool insuranceApplicationEditable = sourceSite == Site.AssociatePortal &&
                associate.AssociateApprovalStatusId == (byte)AssociateApprovalStatus.Registered;

            if (sourceSite != Site.Admin)
            {
                associate.VettingContactId = originalAssociate.VettingContactId;
                associate.ReferralName = originalAssociate.ReferralName;
                associate.ReferralByFriendName = originalAssociate.ReferralByFriendName;
                associate.ReferralByFriendEmail = originalAssociate.ReferralByFriendEmail;
                associate.IdentityDocumentsQualityChecked = originalAssociate.IdentityDocumentsQualityChecked;
            }

            if (!insuranceApplicationEditable)
            {
                associate.RequiresHiscoxInsurance = originalAssociate.RequiresHiscoxInsurance;
            }

            // Check if a new self billing document is required due to changes in LTD company details
            CheckNewBillingDocumentRequirement(associate, originalAssociate);

            // longitude and latitude
            if (originalAssociate.Postcode != associate.Postcode || originalAssociate.AddressData != associate.AddressData)
            {
                var postcode = associate.Postcode;
                if (postcode == null)
                {
                    var jss = new JavaScriptSerializer();
                    Dictionary<string, object> d = jss.Deserialize<dynamic>(associate.AddressData);

                    // fill in the to address
                    if (d["ZipPostcode"] != null)
                    {
                        postcode = d["ZipPostcode"].ToString();
                    }
                }

                var postcodes = this.MomentaDb.PostCode;

                postcode = postcode.Replace(" ", string.Empty).ToLower();

                var match = from p in postcodes
                            where p.postcode.Replace(" ", string.Empty).ToLower() == postcode
                            select new { p.longitude, p.latitude };

                var coords = match.FirstOrDefault();

                if (coords != null)
                {
                    associate.Latitude = coords.latitude;
                    associate.Longitude = coords.longitude;
                }
            }

            // update the membership email address if need be
            if (originalAssociate.Email != associate.Email)
            {
                var userId = originalAssociate.aspnet_Users.UserId;

                var user = this.MomentaDb.aspnet_Users.Where(x => x.UserId == userId).First();
                var member = this.MomentaDb.aspnet_Membership.Where(x => x.UserId == userId).First();

                user.UserName = associate.Email;
                user.LoweredUserName = associate.Email.ToLower();

                member.Email = associate.Email;
                member.LoweredEmail = associate.Email.ToLower();
            }

            // Update Associate changes
            this.MomentaDb.Associates.ApplyCurrentValues(associate);

            if (insuranceApplicationEditable && associate.RequiresHiscoxInsurance == true)
            {
                if (originalAssociate.InsuranceApplication == null)
                {
                    originalAssociate.InsuranceApplication = associate.InsuranceApplication;
                    originalAssociate.InsuranceApplication.InsuranceApplicationStatusId = 1;
                }
                else
                {
                    associate.InsuranceApplication.AssociateId = originalAssociate.ID;
                    associate.InsuranceApplication.InsuranceApplicationStatusId = originalAssociate.InsuranceApplication.InsuranceApplicationStatusId;
                    this.MomentaDb.InsuranceApplications.ApplyCurrentValues(associate.InsuranceApplication);
                }
            }

            while (associate.Comments.Any())
            {
                originalAssociate.Comments.Add(associate.Comments.First());
            }

            var originalMarketSectorRoles = originalAssociate.MarketSectorRoles.ToList();
            var currentMarketSectorRoles = associate.MarketSectorRoles.ToList();

            var addedMarketSectorRoles = IEnumerableT.AntiJoin(currentMarketSectorRoles, originalMarketSectorRoles, (a, b) => a.MarketSectorRoleId == b.MarketSectorRoleId);
            var deletedMarketSectorRoles = IEnumerableT.AntiJoin(originalMarketSectorRoles, currentMarketSectorRoles, (a, b) => a.MarketSectorRoleId == b.MarketSectorRoleId);

            foreach (var deletedMarketSectorRole in deletedMarketSectorRoles)
            {
                originalAssociate.MarketSectorRoles.Remove(deletedMarketSectorRole);
            }

            foreach (var addedMarketSectorRole in addedMarketSectorRoles)
            {
                var marketSectorRole = new MarketSectorRole { MarketSectorRoleId = addedMarketSectorRole.MarketSectorRoleId };
                this.MomentaDb.MarketSectorRoles.Attach(marketSectorRole);
                originalAssociate.MarketSectorRoles.Add(marketSectorRole);
            }

            var originalQualifications = originalAssociate.Qualifications.ToList();
            var currentQualifications = associate.Qualifications.ToList();

            var addedQualifications = IEnumerableT.AntiJoin(currentQualifications, originalQualifications, (a, b) => a.QualificationId == b.QualificationId);
            var deletedQualifications = IEnumerableT.AntiJoin(originalQualifications, currentQualifications, (a, b) => a.QualificationId == b.QualificationId);

            foreach (var deletedQualification in deletedQualifications)
            {
                originalAssociate.Qualifications.Remove(deletedQualification);
            }

            foreach (var addedQualification in addedQualifications)
            {
                var qualification = new Qualification { QualificationId = addedQualification.QualificationId };
                this.MomentaDb.Qualifications.Attach(qualification);
                originalAssociate.Qualifications.Add(qualification);
            }

            var originalQualificationFreeTexts = originalAssociate.AssociateQualificationFreeTexts.ToList();
            var currentQualificationFreeTexts = associate.AssociateQualificationFreeTexts.ToList();

            var addedQualificationFreeTexts = IEnumerableT.AntiJoin(currentQualificationFreeTexts, originalQualificationFreeTexts, (a, b) => a.AssociateId == b.AssociateId && a.MarketSectorId == b.MarketSectorId);

            foreach (var associateQualificationFreeText in addedQualificationFreeTexts)
            {
                originalAssociate.AssociateQualificationFreeTexts.Add(associateQualificationFreeText);
            }

            foreach (var qft in associate.AssociateQualificationFreeTexts)
            {
                this.MomentaDb.AssociateQualificationFreeTexts.ApplyCurrentValues(qft);
            }

            foreach (var associateQualificationFreeText in originalAssociate.AssociateQualificationFreeTexts.ToList())
            {
                if (string.IsNullOrWhiteSpace(associateQualificationFreeText.FreeText))
                {
                    originalAssociate.AssociateQualificationFreeTexts.Remove(associateQualificationFreeText);
                }
            }

            var originalSpecialisms = originalAssociate.Specialism.ToList();
            var currentSpecialisms = associate.Specialism.ToList();

            var addedSpecialisms = IEnumerableT.AntiJoin(currentSpecialisms, originalSpecialisms, (a, b) => a.SpecialismId == b.SpecialismId);
            var deletedSpecialisms = IEnumerableT.AntiJoin(originalSpecialisms, currentSpecialisms, (a, b) => a.SpecialismId == b.SpecialismId);

            foreach (var deletedSpecialism in deletedSpecialisms)
            {
                originalAssociate.Specialism.Remove(deletedSpecialism);
            }

            foreach (var addedSpecialism in addedSpecialisms)
            {
                var specialism = new Specialism { SpecialismId = addedSpecialism.SpecialismId };
                this.MomentaDb.Specialism.Attach(specialism);
                originalAssociate.Specialism.Add(specialism);
            }

            // Compare with original regions
            var regionsOld = originalAssociate.Regions.ToList();
            foreach (var regionOld in regionsOld)
            {
                // Delete old regions that aren't in the new associate
                if (!associate.Regions.Select(s => s.Id).Contains(regionOld.Id))
                {
                    originalAssociate.Regions.Remove(regionOld);
                }
            }

            foreach (var regionNew in associate.Regions.ToList())
            {
                // Add new regions that aren't in the old associate
                if (!regionsOld.Select(s => s.Id).Contains(regionNew.Id))
                {
                    // TODO: Optimise so that we dont have to query the child
                    var region = this.MomentaDb.Regions.Single(s => s.Id == regionNew.Id);
                    originalAssociate.Regions.Add(region);
                }
            }

            this.UpdateReferences(associate, sourceSite, originalAssociate);

            // Add any new addresses
            // We cannot use a foreach loop because when you call originalAssociate.AssociateAddressHistories.Add(address),
            // the entity gets removed from associate.AssociateAddressHistories, thus rendering the existing enumerator
            // invalid, causing an exception
            // http://stackoverflow.com/questions/5538974/the-relationship-could-not-be-changed-because-one-or-more-of-the-foreign-key-pro
            while (associate.AssociateAddressHistories.Any(r => r.ID <= 0))
            {
                var associateAddressHistory = associate.AssociateAddressHistories.FirstOrDefault(r => r.ID <= 0);
                associateAddressHistory.HasHadEndDate = associateAddressHistory.EndDate.HasValue;
                originalAssociate.AssociateAddressHistories.Add(associateAddressHistory);
            }

            // Update any changes in existing addresses
            // After all the new addresses have been added to originalAssociate.AssociateAddressHistories
            // and thus removed from associate.AssociateAddressHistories (see above), the remainder addresses
            // must be the updates.
            foreach (var address in associate.AssociateAddressHistories)
            {
                /* Check we aren't dealing with an address that existed when the page was first loaded but since deleted in another tab / session. */
                var qualifiedEntitySetName =
                    this.MomentaDb.DefaultContainerName + "." + ObjectContext.GetEntitySetName(this.MomentaDb, address);

                // "MomentaRecruitmentEntities.AssociateAddressHistories";
                var entityKey = address.EntityKey ?? new EntityKey(qualifiedEntitySetName, "ID", address.ID);

                object a;
                this.MomentaDb.TryGetObjectByKey(entityKey, out a);

                if (a != null)
                {
                    address.HasHadEndDate = (((AssociateAddressHistory)a).HasHadEndDate == true) || address.EndDate.HasValue;
                    this.MomentaDb.AssociateAddressHistories.ApplyCurrentValues(address);
                }
            }

            this.MomentaDb.SaveChanges();

            this.MomentaDb.ClearAssociateBusinessAreas(associate.ID);

            foreach (var area in associate.BusinessArea)
            {
                this.MomentaDb.InsertAssociateBusinessArea(associate.ID, area.BusinessAreaId);
            }

            return originalAssociate;
        }
 public async System.Threading.Tasks.Task Delete(Associate entity)
 {
     await _session.DeleteAsync(entity);
 }
 public async System.Threading.Tasks.Task Save(Associate entity)
 {
     await _session.SaveOrUpdateAsync(entity);
 }
예제 #16
0
        private void UpdateReferences(Associate associate, Site sourceSite, Associate originalAssociate)
        {
            var preExistingDocuments = new List<ReferenceDocumentDetails>();
            this.GatherListOfPreExistingDocumentsInNewReferences(preExistingDocuments, associate.AssociateReferenceDetails);

            foreach (ReferenceDocumentDetails referenceDocumentDetails in preExistingDocuments)
            {
                this.MomentaDb.Documents.ApplyCurrentValues(referenceDocumentDetails.ReferenceDocument.Document);

                referenceDocumentDetails.Reference.ReferenceDocuments.Remove(referenceDocumentDetails.ReferenceDocument);
            }

            // Add any new references
            // We cannot use a foreach loop because when you call originalAssociate.AssociateReferenceDetails.Add(reference),
            // the entity gets removed from associate.AssociateReferenceDetails, thus rendering the existing enumerator
            // invalid, causing an exception
            // http://stackoverflow.com/questions/5538974/the-relationship-could-not-be-changed-because-one-or-more-of-the-foreign-key-pro
            while (associate.AssociateReferenceDetails.Any(r => r.ID <= 0))
            {
                AssociateReferenceDetail associateReferenceDetail =
                    associate.AssociateReferenceDetails.First(r => r.ID <= 0);

                foreach (AssociateReferenceDetail subReference in associateReferenceDetail.SubReferences)
                {
                    subReference.ContactPermission = associateReferenceDetail.ContactPermission;

                    foreach (ReferenceDocument referenceDocument in subReference.ReferenceDocuments)
                    {
                        this.SetReferenceDocumentEntityState(referenceDocument);
                    }
                }

                originalAssociate.AssociateReferenceDetails.Add(associateReferenceDetail);

                foreach (ReferenceDocument referenceDocument in associateReferenceDetail.ReferenceDocuments)
                {
                    this.SetReferenceDocumentEntityState(referenceDocument);
                }
            }

            // Update any changes in existing references
            // After all the new references have been added to originalAssociate.AssociateReferenceDetails
            // and thus removed from associate.AssociateReferenceDetails (see above), the remainder references
            // must be the updates.
            foreach (AssociateReferenceDetail reference in associate.AssociateReferenceDetails)
            {
                AssociateReferenceDetail originalReference =
                    originalAssociate.AssociateReferenceDetails.FirstOrDefault(r => r.ID == reference.ID);

                if (originalReference == null)
                {
                    /* this can happen if the page was loaded whilst the reference exists but it
                       was since deleted in another session. */
                    continue;
                }

                if (sourceSite == Site.AssociatePortal && originalReference.LockedOnPortal)
                {
                    /*
                     * this can happen if they hack the reference ids submitted to the server or if they resubmit an old request.
                     * if the reference should be locked for editing on the Associate Portal and the source is AP then skip it.
                     */
                    continue;
                }

                this.MomentaDb.AssociateReferenceDetails.ApplyCurrentValues(reference);

                foreach (ReferenceDocument refDoc in reference.ReferenceDocuments)
                {
                    this.ApplyReferenceDocumentUpdates(sourceSite, refDoc);
                }

                // Add any new accountants (see above notes about adding new references)
                while (reference.SubReferences.Any(a => a.ID <= 0))
                {
                    AssociateReferenceDetail subReference = reference.SubReferences.First(a => a.ID <= 0);
                    subReference.ContactPermission = reference.ContactPermission;
                    originalReference.SubReferences.Add(subReference);

                    foreach (ReferenceDocument referenceDocument in subReference.ReferenceDocuments)
                    {
                        this.SetReferenceDocumentEntityState(referenceDocument);
                    }
                }

                // Update any changes in existing accountants
                foreach (AssociateReferenceDetail accountant in reference.SubReferences)
                {
                    accountant.ContactPermission = reference.ContactPermission;
                    AssociateReferenceDetail originalSubReference = this.MomentaDb.AssociateReferenceDetails.FirstOrDefault(r => r.ID == accountant.ID);

                    this.MomentaDb.AssociateReferenceDetails.ApplyCurrentValues(accountant);

                    foreach (ReferenceDocument refDoc in accountant.ReferenceDocuments)
                    {
                        this.ApplyReferenceDocumentUpdates(sourceSite, refDoc);
                    }
                }
            }

            foreach (ReferenceDocumentDetails referenceDocumentDetails in preExistingDocuments)
            {
                AssociateReferenceDetail reference = referenceDocumentDetails.Reference;

                var rd = new ReferenceDocument
                {
                    ReferenceId = reference.ID,
                    DocumentId = referenceDocumentDetails.ReferenceDocument.DocumentId
                };

                reference.ReferenceDocuments.Add(rd);
            }
        }
예제 #17
0
 private static void CheckNewBillingDocumentRequirement(Associate associate, Associate originalAssociate)
 {
     if (associate.OptOutSelfBilling != true || associate.RequireNewSelfBillingDoc != true)
     {
         if (originalAssociate.VATRegistration != associate.VATRegistration ||
             originalAssociate.RegisteredCompanyName != associate.RegisteredCompanyName ||
             originalAssociate.RegisteredCompanyAddress != associate.RegisteredCompanyAddress ||
             originalAssociate.LimitedCompanyNumber != associate.LimitedCompanyNumber ||
             originalAssociate.VATRegistered != associate.VATRegistered)
         {
             associate.RequireNewSelfBillingDoc = true;
         }
     }
 }
예제 #18
0
파일: BinaryOp.cs 프로젝트: hultqvist/lax
 BinaryOp(string op, int precedence, Associate associate)
     : base(ExprType.BinaryOp, precedence, associate)
 {
     this.Operator = op;
 }
예제 #19
0
        private static bool DetermineNoticeAvailability(int noticePeriod, int interval, Associate x, DateTime today)
        {
            // immediately available
            var currentlyAvailable = (byte?)AvailabilityTypeEnum.CurrentlyAvailable;

            if (x.AvailabilityTypeId == currentlyAvailable)
            {
                return(true);
            }

            // on contract
            var onContract = (byte?)AssociateApprovalStatusEnum.OnContract;

            if (x.AssociateApprovalStatusId == onContract)
            {
                // associates on more than one contract are not available
                if (x.Individual.Count > 1)
                {
                    return(false);
                }

                // todo: lookup the notice period from the requirement
                var associateNoticePeriod = x.NoticePeriod.Value * interval;

                var availableDate = x.AvailableDate.Value;

                var available = today.AddDays(associateNoticePeriod);

                return(availableDate <= available);
            }

            // permanently employee
            var permanentlyEmployed = (byte?)AvailabilityTypeEnum.PermanentlyEmployed;

            if (x.AvailabilityTypeId == permanentlyEmployed)
            {
                if (x.NoticePeriod == null)
                {
                    return(false);
                }

                var associateNoticePeriod = x.NoticePeriod.Value * interval;
                return(associateNoticePeriod <= noticePeriod);
            }

            // temporary/contract with notice
            var withNotice = (byte?)AvailabilityTypeEnum.TemporaryContractWithNotice;

            if (x.AvailabilityTypeId == withNotice)
            {
                if (x.NoticePeriod == null || x.AvailableDate == null)
                {
                    return(false);
                }

                var associateNoticePeriod = x.NoticePeriod.Value * interval;

                var availableDate = x.AvailableDate.Value;

                var available = today.AddDays(associateNoticePeriod);

                return(availableDate <= available);
            }

            return(false);
        }
예제 #20
0
        public AssosciateResult UpdateAssociate(AssociateModel oAssociate)
        {
            Status               oStatus        = new Status();
            Associate            asso           = new Associate();
            AssosciateDataAccess assosciateRepo = new AssosciateDataAccess();

            asso.Associate_ID    = oAssociate.Associate_ID;
            asso.Name            = oAssociate.Name;
            asso.Email           = oAssociate.Email;
            asso.Mobile          = oAssociate.Mobile;
            asso.Pic             = oAssociate.Pic;
            asso.Gender          = oAssociate.Gender;
            asso.Status_Green    = oAssociate.Status_Green;
            asso.Status_Blue     = oAssociate.Status_Blue;
            asso.Status_Red      = oAssociate.Status_Red;
            asso.Level_1         = oAssociate.Level_1;
            asso.Level_2         = oAssociate.Level_2;
            asso.Level_3         = oAssociate.Level_3;
            asso.Remark          = oAssociate.Remark;
            asso.Strength        = oAssociate.Strength;
            asso.Weakness        = oAssociate.Weakness;
            asso.AssociateSkills = null;

            if (asso.Associate_ID == 0)
            {
                asso    = assosciateRepo.AddAssociate(asso);
                oStatus = new Status()
                {
                    Message = "Associate added successfully", Result = true
                };
            }
            else
            {
                asso.Associate_ID = oAssociate.Associate_ID;
                asso    = assosciateRepo.UpdateAssociate(asso);
                oStatus = new Status()
                {
                    Message = "Associate updated successfully", Result = true
                };
            }

            return(new AssosciateResult()
            {
                status = oStatus,
                associateModel = new AssociateModel
                {
                    Associate_ID = asso.Associate_ID,
                    Name = asso.Name,
                    Email = asso.Email,
                    Mobile = asso.Mobile,
                    Pic = asso.Pic,
                    Gender = asso.Gender,
                    Status_Green = asso.Status_Green,
                    Status_Blue = asso.Status_Blue,
                    Status_Red = asso.Status_Red,
                    Level_1 = asso.Level_1,
                    Level_2 = asso.Level_2,
                    Level_3 = asso.Level_3,
                    Remark = asso.Remark,
                    Strength = asso.Strength,
                    Weakness = asso.Weakness,
                    AssociateSkills = null
                }
            });
        }
예제 #21
0
        public MainWindow()
        {
            InitializeComponent();
            User        user1 = new User("user1", "pass1");
            User        user2 = new User("user2", "pass2");
            List <User> list  = new List <User>();

            list.Add(user1);
            list.Add(user2);
            Users      users     = new Users(list);
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream("../../Files/users.txt", FileMode.Create, FileAccess.Write);

            formatter.Serialize(stream, users);
            stream.Close();
            stream = new FileStream("../../Files/users.txt", FileMode.Open, FileAccess.Read);
            Users users2 = (Users)formatter.Deserialize(stream);

            stream.Close();
            foreach (var u in users2.users)
            {
                Console.WriteLine(u.username);
                Console.WriteLine(u.password);
            }
            stream = new FileStream("../../Files/associates.txt", FileMode.Create, FileAccess.Write);
            Associate        as1   = new Associate("as1", "pl1", "restaurant", "555-111");
            Associate        as2   = new Associate("as2", "pl1", "catering firm", "555-222");
            Associate        as3   = new Associate("as3", "pl2", "catering firm", "555-333");
            Associate        as4   = new Associate("as4", "pl2", "restaurant", "555-444");
            Associate        as5   = new Associate("as5", "pl2", "restaurant", "555-555");
            Associate        as6   = new Associate("as6", "pl2", "catering firm", "555-666");
            List <Associate> list2 = new List <Associate>();

            list2.Add(as6);
            list2.Add(as5);
            list2.Add(as4);
            list2.Add(as3);
            list2.Add(as2);
            list2.Add(as1);
            Associates associates = new Associates(list2);

            formatter.Serialize(stream, associates);
            stream.Close();
            Request        re1   = new Request("client1", "birthday", new DateTime(2021, 6, 20, 12, 30, 0), "pl1", 1000, "user1");
            Request        re2   = new Request("client2", "birthday party", new DateTime(2021, 6, 21, 12, 00, 0), "pl1", 3500, "user1");
            Request        re3   = new Request("client3", "promotion", new DateTime(2021, 6, 22, 12, 30, 0), "pl2", 5000, "user1");
            Request        re4   = new Request("client4", "promotion party", new DateTime(2021, 6, 22, 12, 30, 0), "pl2", 5000, "user1");
            Request        re5   = new Request("client5", "retirement party", new DateTime(2021, 6, 20, 14, 30, 0), "pl2", 4500, "user1");
            Request        re6   = new Request("client6", "birthday", new DateTime(2021, 6, 20, 13, 30, 0), "pl1", 4000, "user2");
            Request        re7   = new Request("client7", "birthday party", new DateTime(2021, 6, 21, 12, 00, 0), "pl1", 4000, "user2");
            Request        re8   = new Request("client8", "promotion", new DateTime(2021, 6, 22, 12, 30, 0), "pl1", 4500, "user2");
            Request        re9   = new Request("client9", "promotion party", new DateTime(2021, 6, 22, 12, 30, 0), "pl2", 4000, "user2");
            Request        re10  = new Request("client10", "retirement party", new DateTime(2021, 6, 20, 14, 30, 0), "pl2", 3000, "user2");
            List <Request> list3 = new List <Request>();

            list3.Add(re1);
            list3.Add(re2);
            list3.Add(re3);
            list3.Add(re4);
            list3.Add(re5);
            list3.Add(re6);
            list3.Add(re7);
            list3.Add(re8);
            list3.Add(re9);
            list3.Add(re10);
            Requests requests = new Requests(list3);

            stream = new FileStream("../../Files/requests.txt", FileMode.Create, FileAccess.Write);
            formatter.Serialize(stream, requests);
            stream.Close();
            Offers offers = new Offers(new List <Offer>());

            stream = new FileStream("../../Files/sentOffers.txt", FileMode.Create, FileAccess.Write);
            formatter.Serialize(stream, offers);
            stream.Close();
        }
예제 #22
0
 public int EditAssociate(Associate inputAssociate)
 {
     return(this._associateRepo.EditAssociate(inputAssociate));
 }
예제 #23
0
        //Тип поиска
        private void TypeFind()
        {
            string[] queriesMenu =
            { "Поиск Student.", "Поиск Associate.", "Поиск Teacher.", "Назад." };
            while (true)
            {
                var sw = Print.Menu(0, queriesMenu);
                switch (sw)
                {
                case 1:
                    IPerson person = new Student();
                    person.Input();
                    if (_persons.ContainsKey(person.Return_SeName() + " " + person.Return_Name()))
                    {
                        Console.WriteLine(
                            "Введенный элемент - {0}.\n\n\nДля продолженния нажать на любую клавишу...",
                            _persons[person.Return_SeName() + " " + person.Return_Name()]);
                    }
                    else
                    {
                        Console.WriteLine(
                            "Заданный объект не был найден в стэке.\n\n\nДля продолженния нажать на любую клавишу...");
                    }

                    Console.ReadKey(true);
                    break;

                case 2:
                    person = new Associate();
                    person.Input();
                    if (_persons.ContainsKey(person.Return_SeName() + " " + person.Return_Name()))
                    {
                        Console.WriteLine(
                            "Введенный элемент - {0}.\n\n\nДля продолженния нажать на любую клавишу...",
                            _persons[person.Return_SeName() + " " + person.Return_Name()]);
                    }
                    else
                    {
                        Console.WriteLine(
                            "Заданный объект не был найден в стэке.\n\n\nДля продолженния нажать на любую клавишу...");
                    }

                    Console.ReadKey(true);
                    break;

                case 3:
                    person = new Teacher();
                    person.Input();
                    if (_persons.ContainsKey(person.Return_SeName() + " " + person.Return_Name()))
                    {
                        Console.WriteLine(
                            "Введенный элемент - {0}.\n\n\nДля продолженния нажать на любую клавишу...",
                            _persons[person.Return_SeName() + " " + person.Return_Name()]);
                    }
                    else
                    {
                        Console.WriteLine(
                            "Заданный объект не был найден в стэке.\n\n\nДля продолженния нажать на любую клавишу...");
                    }

                    Console.ReadKey(true);
                    break;

                case 4:
                    return;
                }
            }
        }
예제 #24
0
        private static bool DetermineIfAssociateAvailableTo(int noticePeriod, int interval, Associate x)
        {
            // immediately available
            var currentlyAvailable = (byte?)AvailabilityTypeEnum.CurrentlyAvailable;
            if (x.AvailabilityTypeId == currentlyAvailable)
            {
                return true;
            }

            // todo: permanently employee
            // todo: temporary/contract with notice
            return false;
        }
예제 #25
0
        //Удалить объект
        private void Delete(out int k)
        {
            string[] addMenu =
            { "Удалить студента.", "Удалить сотрудника.", "Удалить учителя.", "Назад." };
            k = 0;
            while (true)
            {
                var     sw = Print.Menu(0, addMenu);
                IPerson person;
                switch (sw)
                {
                case 1:
                    Console.WriteLine("Введите студента для удаления:");
                    person = new Student();
                    person.Input();

                    if (!_persons.ContainsKey(person.Return_SeName() + " " + person.Return_Name()))
                    {
                        Console.WriteLine(
                            "Объект для удаления отсутсвует в словаре.\n\n\nДля продолженния нажать на любую клавишу...");
                        Console.ReadKey(true);
                    }
                    else
                    {
                        _persons.Remove(person.Return_SeName() + " " + person.Return_Name());
                        Console.WriteLine(
                            "Объект успешно удален.\n\n\nДля продолженния нажать на любую клавишу...");
                        Console.ReadKey(true);
                    }

                    if (_persons.Count == 0)
                    {
                        k = 6;
                        return;
                    }

                    break;

                case 2:
                    Console.WriteLine("Введите сотрудника для удаления:");
                    person = new Associate();
                    person.Input();
                    if (!_persons.ContainsKey(person.Return_SeName() + " " + person.Return_Name()))
                    {
                        Console.WriteLine(
                            "Объект для удаления отсутсвует в словаре.\n\n\nДля продолженния нажать на любую клавишу...");
                        Console.ReadKey(true);
                    }
                    else
                    {
                        _persons.Remove(person.Return_SeName() + " " + person.Return_Name());
                        Console.WriteLine(
                            "Объект успешно удален.\n\n\nДля продолженния нажать на любую клавишу...");
                        Console.ReadKey(true);
                    }

                    if (_persons.Count == 0)
                    {
                        k = 6;
                        return;
                    }

                    break;

                case 3:
                    Console.WriteLine("Введите учителя для удаления:");
                    person = new Teacher();
                    person.Input();
                    if (!_persons.ContainsKey(person.Return_SeName() + " " + person.Return_Name()))
                    {
                        Console.WriteLine(
                            "Объект для удаления отсутсвует в словаре.\n\n\nДля продолженния нажать на любую клавишу...");
                        Console.ReadKey(true);
                    }
                    else
                    {
                        _persons.Remove(person.Return_SeName() + " " + person.Return_Name());
                        Console.WriteLine(
                            "Объект успешно удален.\n\n\nДля продолженния нажать на любую клавишу...");
                        Console.ReadKey(true);
                    }

                    if (_persons.Count == 0)
                    {
                        k = 6;
                        return;
                    }

                    break;

                case 4:
                    return;
                }
            }
        }
예제 #26
0
        public Associate GetAssociate(Associate associate)
        {
            Associate ObjAssociate = new Associate();

            return(ObjAssociate);
        }
예제 #27
0
 public InsertAssociateCommand(Associate model, ViewModelBase owner) : base(model)
 {
     this.Owner = owner;
 }
예제 #28
0
        public int CreateAssociate(Associate associate, Guid membershipUserId)
        {
            var stubAspNetUser = new aspnet_Users { UserId = membershipUserId };
            this.MomentaDb.aspnet_Users.Attach(stubAspNetUser);

            associate.aspnet_Users = stubAspNetUser;
            this.MomentaDb.Associates.AddObject(associate);

            this.MomentaDb.SaveChanges();

            return associate.ID;
        }
예제 #29
0
 public UpdateAssociateCommand(Associate model) : base(model)
 {
 }
예제 #30
0
        public void SaveComment(Comment commentEntity, int associateId)
        {
            this.MomentaDb.Comments.AddObject(commentEntity);

            if (associateId != 0)
            {
                var associateStub = new Associate { ID = associateId };
                this.MomentaDb.Associates.Attach(associateStub);
                commentEntity.Associate = associateStub;
            }

            this.MomentaDb.SaveChanges();
        }
예제 #31
0
        //public IActionResult Post([FromBody] Associate value)
        //{
        //    int returnval = CRSRepos.AddAssociate(value);
        //    return Ok(returnval);
        //}

        //[HttpPost]
        public IActionResult Post([FromBody] Associate user)
        {
            int id = CRSRepos.AddAssociate(user);

            return(Ok(id));
        }
예제 #32
0
        public void UpdateAssociateToItris(Associate associate, string empId)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(empId));

            string title;
            string businessType;

            if (associate.PersonTitleId == 5)
            {
                title = associate.TitleOther;
            }
            else
            {
                title = this.MomentaDb.PersonTitles
                            .Where(t => t.PersonTitleId == associate.PersonTitleId)
                            .Select(t => t.Description)
                            .FirstOrDefault();
            }

            switch ((BusinessType?)associate.BusinessTypeID)
            {
                case BusinessType.ContractLtdCompany:
                    businessType = "L";
                    break;
                case BusinessType.Umbrella:
                    businessType = "U";
                    break;
                default:
                    businessType = null;
                    break;
            }

            this.ItrisDb.ip_SetApplicantsName(
                appID: associate.ITRISAppId,
                title: title,
                first: associate.FirstName,
                middle: associate.MiddleName,
                last: associate.LastName,
                userID: empId);

            this.ItrisDb.ip_UpdateApplicantDetails(
                appID: associate.ITRISAppId,
                empID: empId,
                qComments: string.Empty,
                forceUpdate: false,
                tFlags: null,
                oFlags: null,
                deleted: null,
                lastContacted: null,
                eMail: null,
                homeTel: null,
                workTel: null,
                mobileTel: null,
                otherTel: associate.OtherPhone,
                address: null,
                postCode: null,
                wEBAddress: null,
                dOB: null,
                lastCV: null,
                lastTyped: null,
                typeID: null,
                ownerID: null,
                fAOOf: null,
                nationID: null,
                currentPosition: null);

            ////this.ItrisDb.SaveChanges();
            this.ItrisDb.ip_UpdatePersonalDetails(
                appID: associate.ITRISAppId,
                vISA_EXPIRY: associate.HasVisa.Value ? associate.VisaExpiry : null,
                visaType: associate.HasVisa.Value ? this.MomentaDb.VisaTypes.Where(v => v.ID == associate.VisaTypeId.Value).Select(v => v.Name).Single() : null,
                vISA_NO: associate.HasVisa.Value ? associate.VisaNumber : null,
                nI_NUMBER: associate.NI,
                tAX_CODE: null,
                nI_CODE_LETTER: null,
                pASSPORT_NO: associate.PassportNumber,
                dAYS_PER_WEEK: null,
                iD_VERIFIED: null,
                vERIFIED_BY: null,
                vAT_REGISTERED: null,
                vAT_REG_NO: null,
                bUSINESS_TYPE: businessType,
                tRADE_NAME: null,
                tRADE_DESCRIPTION: null,
                tRADE_ADDRESS: null,
                tRADE_POST_CODE: null,
                cOMP_REG_NO: null,
                sTUDENT: null,
                bANK_NAME: null,
                bANK_ADDRESS: null,
                aCCOUNT_NO: null,
                sORT_CODE: null,
                aCCOUNT_NAME: null,
                bANKBUILD_REF: null,
                sWIFT_CODE: null,
                iBAN_NUMBER: null,
                eMP_ID: null,
                gENDER: null,
                mARITAL_STATUS: null,
                umbrellaCompanyID: null);

            this.ItrisDb.ip_SetAppAvailability(
                appID: associate.ITRISAppId,
                date: associate.AvailabilityTypeId != 1 ? associate.AvailableDate : null,
                nextCallDate: null,
                notice: associate.AvailabilityTypeId == 2 ? associate.NoticePeriod : 0,
                workType: associate.AvailabilityTypeId,
                noticeType: associate.AvailabilityTypeId == 2 ? associate.NoticeIntervalId : null);

            this.ItrisDb.ip_UpdateMainApplicantDetails(
                appID: associate.ITRISAppId,
                firstName: associate.FirstName,
                middleName: associate.MiddleName,
                lastName: associate.LastName,
                address: associate.UnitNumber + " " + associate.HouseName + " " + associate.HouseNumber + " " + associate.Street + " " + associate.Town,
                postCode: associate.Postcode,
                mobileTel: associate.MobilePhone,
                homeTel: associate.HomePhone,
                workTel: associate.WorkPhone,
                dOB: associate.DateOfBirth,
                nationID: null,
                email: associate.Email,
                rate: null,
                salary: null,
                currency: null,
                rateIntvl: null,
                about: null);

            // ip_UpdateApplicantStatus
            // @AppID CHAR(10) ,
            // @StatusID INT

            // ip_UpdateComment
            // @CommentID INT ,
            // @FormID TINYINT ,
            // @RecordID CHAR(10) ,
            // @AltAppID CHAR(10) ,
            // @AltCompanyID CHAR(10) ,
            // @AltContactID CHAR(10) ,
            // @AltJobID CHAR(10) ,
            // @AltPlaceID CHAR(10) ,
            // @AltUserEmpID CHAR(10) ,
            // @AltPreRegID INT ,
            // @EmpID CHAR(10) ,
            // @Type INT ,
            // @Comment VARCHAR(1000) ,
            // @SpokenTo TINYINT ,
            // @AltAgencyID INT = NULL ,
            // @AltAgencyAppID INT = NULL ,
            // @AltAgencyContactID INT = NULL
            this.ItrisDb.SaveChanges();
        }
예제 #33
0
 public void AssociateWorkForClient(Associate associate, Client client)
 {
     associate.OnAssociateReturnBackToClient   += associateReturnBackToClientHandler.Handle;
     associate.OnAssociateStartWorkingAtClient += associateStartedWorkingAtClientHandler.Handle;
     associate.AssociateWorkForClient(client);
 }
예제 #34
0
 protected Operator(ExprType type, int precedence, Associate associate) : base(type)
 {
     this.Precedence = precedence;
     this.Associate = associate;
 }
예제 #35
0
        public void TestMethod_MapSkillsToAssociate_Success()
        {
            //// Add Skills First
            Skill skill1 = new Skill {
                Id = -10, Name = "UnitTest_MapSkill_Success_1", IsTechnical = true
            };
            var postResponse_skill1 = this._skillController.PostSkill(skill1);

            Assert.IsNotNull(postResponse_skill1);
            var postResult_skill1 = postResponse_skill1 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult_skill1);
            Assert.IsNotNull(postResult_skill1.Content);
            Assert.GreaterOrEqual(postResult_skill1.Content, 1);
            int skill1_id = postResult_skill1.Content;

            Skill skill2 = new Skill {
                Id = -11, Name = "UnitTest_MapSkill_Success_2", IsTechnical = true
            };
            var postResponse_skill2 = this._skillController.PostSkill(skill2);

            Assert.IsNotNull(postResponse_skill2);
            var postResult_skill2 = postResponse_skill2 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult_skill2);
            Assert.IsNotNull(postResult_skill2.Content);
            Assert.GreaterOrEqual(postResult_skill2.Content, 1);
            int skill2_id = postResult_skill2.Content;

            Skill skill3 = new Skill {
                Id = -12, Name = "UnitTest_MapSkill_Success_3", IsTechnical = false
            };
            var postResponse_skill3 = this._skillController.PostSkill(skill3);

            Assert.IsNotNull(postResponse_skill3);
            var postResult_skill3 = postResponse_skill3 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult_skill3);
            Assert.IsNotNull(postResult_skill3.Content);
            Assert.GreaterOrEqual(postResult_skill3.Content, 1);
            int skill3_id = postResult_skill3.Content;

            //// Add Associate
            Associate associate = new Associate {
                Id = -4, Name = "UnitTest_MapSkillsToAssociate", Email = "*****@*****.**", Mobile = "+1 11111111", Picture = "", Status = "Green", Level = 1, Remark = "Top performer", Strength = "Coding", Weakness = "Team Building", Gender = "M", IsFresher = false, OtherSkill = "CSR Related Works"
            };
            var postResponse = this._associateController.PostAssociate(associate);

            Assert.IsNotNull(postResponse);

            var postResult = postResponse as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult);
            Assert.IsNotNull(postResult.Content);
            Assert.AreEqual(postResult.Content, 1);

            //// Mao Skills to Associate
            var mapResponse = this._associateController.MapSkillsToAssociate(-4, new List <AssociateSkill>
            {
                new AssociateSkill {
                    AssociateId = -4, SkillId = skill1_id, Rating = 10
                },
                new AssociateSkill {
                    AssociateId = -4, SkillId = skill2_id, Rating = 20
                }
            });

            Assert.IsNotNull(mapResponse);

            var mapResult = mapResponse as OkNegotiatedContentResult <bool>;

            Assert.IsNotNull(mapResult);
            Assert.IsNotNull(mapResult.Content);
            Assert.AreEqual(mapResult.Content, true);

            var getAllResponse = this._associateController.GetMappedSkillsOfAssociate(-4);

            Assert.IsNotNull(getAllResponse);

            var getAllResult = getAllResponse as OkNegotiatedContentResult <List <SkillMapForAssociate> >;

            Assert.IsNotNull(getAllResult);
            Assert.IsNotNull(getAllResult.Content);
            Assert.GreaterOrEqual(getAllResult.Content.Count, 3);
            Assert.AreEqual(getAllResult.Content.Where(w => w.IsSelected).Count(), 2);
            Assert.AreEqual(getAllResult.Content.Where(w => w.Name == "UnitTest_MapSkill_Success_1" && w.IsSelected).Count(), 1);
            Assert.AreEqual(getAllResult.Content.Where(w => w.Name == "UnitTest_MapSkill_Success_2" && w.IsSelected).Count(), 1);

            //// Update
            var mapResponse2 = this._associateController.MapSkillsToAssociate(-4, new List <AssociateSkill>
            {
                new AssociateSkill {
                    AssociateId = -4, SkillId = skill2_id, Rating = 6
                },
                new AssociateSkill {
                    AssociateId = -4, SkillId = skill3_id, Rating = 13
                }
            });

            Assert.IsNotNull(mapResponse2);

            var mapResult2 = mapResponse2 as OkNegotiatedContentResult <bool>;

            Assert.IsNotNull(mapResult2);
            Assert.IsNotNull(mapResult2.Content);
            Assert.AreEqual(mapResult2.Content, true);

            var getAllResponse2 = this._associateController.GetMappedSkillsOfAssociate(-4);

            Assert.IsNotNull(getAllResponse2);

            var getAllResult2 = getAllResponse2 as OkNegotiatedContentResult <List <SkillMapForAssociate> >;

            Assert.IsNotNull(getAllResult2);
            Assert.IsNotNull(getAllResult2.Content);
            Assert.GreaterOrEqual(getAllResult2.Content.Count, 3);
            Assert.AreEqual(getAllResult2.Content.Where(w => w.IsSelected).Count(), 2);
            Assert.AreEqual(getAllResult2.Content.Where(w => w.Name == "UnitTest_MapSkill_Success_1" && w.IsSelected).Count(), 0);
            Assert.AreEqual(getAllResult2.Content.Where(w => w.Name == "UnitTest_MapSkill_Success_2" && w.IsSelected).Count(), 1);
            Assert.AreEqual(getAllResult2.Content.Where(w => w.Name == "UnitTest_MapSkill_Success_3" && w.IsSelected).Count(), 1);
            Assert.AreEqual(getAllResult2.Content.Where(w => w.Name == "UnitTest_MapSkill_Success_2" && w.IsSelected).FirstOrDefault().Rating, 6);
            Assert.AreEqual(getAllResult2.Content.Where(w => w.Name == "UnitTest_MapSkill_Success_3" && w.IsSelected).FirstOrDefault().IsTechnical, false);

            //// Delete
            var mapResponse3 = this._associateController.MapSkillsToAssociate(-4, new List <AssociateSkill>());

            Assert.IsNotNull(mapResponse3);

            var mapResult3 = mapResponse3 as OkNegotiatedContentResult <bool>;

            Assert.IsNotNull(mapResult3);
            Assert.IsNotNull(mapResult3.Content);
            Assert.AreEqual(mapResult3.Content, true);

            var getAllResponse3 = this._associateController.GetMappedSkillsOfAssociate(-4);

            Assert.IsNotNull(getAllResponse3);

            var getAllResult3 = getAllResponse3 as OkNegotiatedContentResult <List <SkillMapForAssociate> >;

            Assert.IsNotNull(getAllResult3);
            Assert.IsNotNull(getAllResult3.Content);
            Assert.GreaterOrEqual(getAllResult3.Content.Count, 3);
            Assert.AreEqual(getAllResult3.Content.Where(w => w.IsSelected).Count(), 0);

            //// CleanUp
            this._skillController.DeleteSkill(skill1_id);
            this._skillController.DeleteSkill(skill2_id);
            this._skillController.DeleteSkill(skill3_id);
            this._associateController.DeleteAssociate(-4);
        }
예제 #36
0
        public void TestMethod_GetSkillReport_Success()
        {
            //// Add Skills First
            Skill skill1 = new Skill {
                Id = -101, Name = "UnitTest_GetSkillReport_Success_1", IsTechnical = true
            };
            var postResponse_skill1 = this._skillController.PostSkill(skill1);

            Assert.IsNotNull(postResponse_skill1);
            var postResult_skill1 = postResponse_skill1 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult_skill1);
            Assert.IsNotNull(postResult_skill1.Content);
            Assert.GreaterOrEqual(postResult_skill1.Content, 1);
            int skill1_id = postResult_skill1.Content;

            Skill skill2 = new Skill {
                Id = -102, Name = "UnitTest_GetSkillReport_Success_2", IsTechnical = true
            };
            var postResponse_skill2 = this._skillController.PostSkill(skill2);

            Assert.IsNotNull(postResponse_skill2);
            var postResult_skill2 = postResponse_skill2 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult_skill2);
            Assert.IsNotNull(postResult_skill2.Content);
            Assert.GreaterOrEqual(postResult_skill2.Content, 1);
            int skill2_id = postResult_skill2.Content;

            Skill skill3 = new Skill {
                Id = -103, Name = "UnitTest_GetSkillReport_Success_3", IsTechnical = false
            };
            var postResponse_skill3 = this._skillController.PostSkill(skill3);

            Assert.IsNotNull(postResponse_skill3);
            var postResult_skill3 = postResponse_skill3 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult_skill3);
            Assert.IsNotNull(postResult_skill3.Content);
            Assert.GreaterOrEqual(postResult_skill3.Content, 1);
            int skill3_id = postResult_skill3.Content;

            //// Add Associate
            Associate associate = new Associate {
                Id = -101, Name = "UnitTest_GetSkillReport", Email = "*****@*****.**", Mobile = "+1 11111111", Picture = "", Status = "Red", Level = 1, Remark = "Top performer", Strength = "Coding", Weakness = "Team Building", Gender = "M", IsFresher = false, OtherSkill = "CSR Related Works"
            };
            var postResponse = this._associateController.PostAssociate(associate);

            Assert.IsNotNull(postResponse);
            var postResult = postResponse as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult);
            Assert.IsNotNull(postResult.Content);
            Assert.AreEqual(postResult.Content, 1);

            Associate associate2 = new Associate {
                Id = -102, Name = "UnitTest_GetSkillReport2", Email = "*****@*****.**", Mobile = "+1 11111111", Picture = "", Status = "Green", Level = 2, Remark = "Top performer", Strength = "Coding", Weakness = "Team Building", Gender = "M", IsFresher = true, OtherSkill = "CSR Related Works"
            };
            var postResponse2 = this._associateController.PostAssociate(associate2);

            Assert.IsNotNull(postResponse2);
            var postResult2 = postResponse2 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult2);
            Assert.IsNotNull(postResult2.Content);
            Assert.AreEqual(postResult2.Content, 1);

            Associate associate3 = new Associate {
                Id = -103, Name = "UnitTest_GetSkillReport3", Email = "*****@*****.**", Mobile = "+1 11111111", Picture = "", Status = "Blue", Level = 1, Remark = "Top performer", Strength = "Coding", Weakness = "Team Building", Gender = "F", IsFresher = false, OtherSkill = "CSR Related Works"
            };
            var postResponse3 = this._associateController.PostAssociate(associate3);

            Assert.IsNotNull(postResponse3);
            var postResult3 = postResponse3 as OkNegotiatedContentResult <int>;

            Assert.IsNotNull(postResult3);
            Assert.IsNotNull(postResult3.Content);
            Assert.AreEqual(postResult3.Content, 1);

            //// Mao Skills to Associate
            var mapResponse = this._associateController.MapSkillsToAssociate(-4, new List <AssociateSkill>
            {
                new AssociateSkill {
                    AssociateId = -101, SkillId = skill1_id, Rating = 14
                },
                new AssociateSkill {
                    AssociateId = -101, SkillId = skill2_id, Rating = 9
                }
            });

            Assert.IsNotNull(mapResponse);
            var mapResult = mapResponse as OkNegotiatedContentResult <bool>;

            Assert.IsNotNull(mapResult);
            Assert.IsNotNull(mapResult.Content);
            Assert.AreEqual(mapResult.Content, true);

            var mapResponse2 = this._associateController.MapSkillsToAssociate(-4, new List <AssociateSkill>
            {
                new AssociateSkill {
                    AssociateId = -102, SkillId = skill2_id, Rating = 11
                },
                new AssociateSkill {
                    AssociateId = -102, SkillId = skill3_id, Rating = 13
                }
            });

            Assert.IsNotNull(mapResponse2);
            var mapResult2 = mapResponse2 as OkNegotiatedContentResult <bool>;

            Assert.IsNotNull(mapResult2);
            Assert.IsNotNull(mapResult2.Content);
            Assert.AreEqual(mapResult2.Content, true);

            //// Get Skill Report
            var getAllResponse = this._associateController.GetSkillReport();

            Assert.IsNotNull(getAllResponse);

            var getAllResult = getAllResponse as OkNegotiatedContentResult <Report>;

            Assert.IsNotNull(getAllResult);
            Assert.IsNotNull(getAllResult.Content);

            Assert.GreaterOrEqual(getAllResult.Content.RegisteredCandidateCount, 3);
            Assert.GreaterOrEqual(getAllResult.Content.RatedCandidateCount, 2);

            Assert.Greater(getAllResult.Content.FemaleCandidatePercentage, 0);
            Assert.Greater(getAllResult.Content.FresherCandidatePercentage, 0);
            Assert.Greater(getAllResult.Content.Level1CandidatePercentage, 0);

            //// CleanUp
            this._associateController.DeleteAssociate(-101);
            this._associateController.DeleteAssociate(-102);
            this._associateController.DeleteAssociate(-103);
            this._skillController.DeleteSkill(skill1_id);
            this._skillController.DeleteSkill(skill2_id);
            this._skillController.DeleteSkill(skill3_id);
        }
예제 #37
0
        public AssociateDao MapToService(Associate associate)
        {
            var mapper = AssociateMapper.CreateMapper();

            return(mapper.Map <AssociateDao>(associate));
        }