public string AddAssociateDetails(AssociateModel associateDetails)
        {
            AssociateDAO associateDAO = new AssociateDAO();
            Associate    associate    = new Associate
            {
                Associate_ID        = associateDetails.AssociateId,
                Name                = associateDetails.Name,
                Email               = associateDetails.Email,
                Mobile              = associateDetails.Mobile,
                Pic                 = associateDetails.Pic,
                Status              = associateDetails.Status,
                Level               = associateDetails.Level,
                Remark              = associateDetails.Remark,
                OtherSkills         = associateDetails.OtherSkills,
                Weekness            = associateDetails.Weekness,
                Strength            = associateDetails.Strength,
                AssociateSkillsList = associateDetails.AssociateSkills
                                      .Select(x => new AssociateSkills
                {
                    Associate_ID         = associateDetails.AssociateId,
                    Associate_Skills_ID  = x.AssociateSkillsId,
                    Associate_Details_ID = associateDetails.AssociateDetailsId,
                    Skill_ID             = x.SkillId,
                    Skill_Rate           = x.SkillRate,
                }).ToList()
            };

            associateDAO.AddAssociate(associate);
            //if (associateDAO.AddAssociate(associate) && associateDetails.AssociateSkills != null && associateDetails.AssociateSkills.Count > 0)
            //{
            //    AssociateSkillsDAO associateSkillsDAO = new AssociateSkillsDAO();
            //    associateSkillsDAO.AddAssociateSkills(associateDetails.AssociateSkills.Select(x => new AssociateSkills { Associate_ID = associate.Associate_ID, Skill_ID = x.SkillId, Skill_Rate = x.SkillRate }).ToList());
            //}
            return("Associate details added successfully");
        }
Exemplo n.º 2
0
        public JsonResult RejectTimesheet(TimesheetViewModel model)
        {
            string userName = this.membershipService.GetCurrentUserName();

            model.TimesheetChecker = userName;
            bool           result;
            AssociateModel currentUserId = null;

            try
            {
                currentUserId = associateService.GetAssociate(User.Identity.Name);
            }
            catch (Exception) { }

            if (currentUserId == null || currentUserId.Id == 0)
            {
                model.CurrentUserId = this.ClientContactVerifiedDetails().ClientContactId;
                result = timesheetService.RejectTimesheet(model, true);
            }
            else
            {
                result = timesheetService.RejectTimesheet(model);
            }
            return(Json(result));
        }
Exemplo n.º 3
0
        public void AcceptAssociate(AssociateModel associate)
        {
            this.associateRepo.UpdateAssociateStatus(associate.Id, AssociateApprovalStatus.Accepted);

            // send associate approval notication
            EmailModel associateSubmission = this.emailService.GetAssociateEmail(associate.Id, EmailTemplate.AssociateAcceptedNotification);

            associateSubmission.ToAddress = associate.Email;
            this.emailService.SendEmail(associateSubmission);
        }
Exemplo n.º 4
0
        public int CreateAssociate(AssociateModel associate, Guid membershipUserId)
        {
            Associate associateEntity = this.dataMapper.MapAssociateM2E(associate);

            associateEntity.AssociateApprovalStatusId = (byte)AssociateApprovalStatus.Accepted;
            associateEntity.CreatedDate  = DateTime.Now;
            associateEntity.AdminOwnerId = this.associateRepo.AssignAssociateOwner(associate.LastName);

            return(this.associateRepo.CreateAssociate(
                       associateEntity, membershipUserId));
        }
Exemplo n.º 5
0
        public IEnumerable <string> ValidateBusinessRules(AssociateModel associate)
        {
            var warnings = new StringBuilder();

            this.ValidateReferences(warnings, associate.References);
            this.ValidateAddresses(warnings, associate.AddressHistory);

            return(warnings.Length == 0
                ? null
                : warnings.ToString().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
        }
Exemplo n.º 6
0
        public Status DeleteAssociate(AssociateModel oAssociate)
        {
            AssosciateDataAccess assosciateRepo = new AssosciateDataAccess();

            assosciateRepo.DeleteAssosciate(new Associate()
            {
                Associate_ID = oAssociate.Associate_ID
            });
            return(new Status()
            {
                Message = "Associate deleted successfully", Result = true
            });
        }
Exemplo n.º 7
0
 public HttpResponseMessage DeleteAssociate([FromBody] AssociateModel associate)
 {
     try
     {
         var input = Helper.CastObject <Associate>(associate);
         _associatesService.RemoveAssociate(input);
     }
     catch (Exception ex)
     {
         _logManager.WriteLog(ex);
     }
     return(ToJson(associate));
 }
Exemplo n.º 8
0
        public HttpResponseMessage GetAssociate([FromBody] AssociateModel associate)
        {
            AssociateModel result = new AssociateModel();

            try
            {
                var res = _associatesService.GetAssociate(associate.Associate_Id);
                result = Helper.CastObject <AssociateModel>(res);
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(result));
        }
Exemplo n.º 9
0
        public void AddAssociateTest()
        {
            var request = new AssociateModel
            {
                Associate_Id     = 575566,
                Name             = "TestAssociate",
                Email            = "*****@*****.**",
                Mobile           = "1234567890",
                Gender           = "Male",
                Status_Blue      = false,
                Status_Green     = true,
                Status_Red       = false,
                Level_1          = true,
                Level_2          = false,
                Level_3          = false,
                Pic              = "",
                Remark           = "Na",
                Strength         = "Na",
                Other            = "Na",
                Weakness         = "",
                Associate_Skills =
                {
                    new AssociateSkillsModel {
                        Associate_Id = 575566, Rating = 5, Skill_Id = 5
                    },
                    new AssociateSkillsModel {
                        Associate_Id = 575566, Rating = 5, Skill_Id = 6
                    }
                }
            };
            var response            = new AssociateModel();
            var associateController = new AssociateController(_associatesService, _logManager)
            {
                Request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(ServiceBaseURL + "associate/addAssociate")
                }
            };

            associateController.Configuration = new HttpConfiguration();
            _response = associateController.AddAssociate(request);
            response  = JsonConvert.DeserializeObject <AssociateModel>(_response.Content.ReadAsStringAsync().Result);
            Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(response != null, true);
            Assert.Greater(response.Associate_Id, 0);
        }
Exemplo n.º 10
0
        private void InsertAssociateToItris(AssociateModel associate, Guid userId)
        {
            // This is the 'Portal' user. Admin site password is 'Portal1'
            // ITRIS ID is 'HQ00000203'
            // For now all records inserted into ITRIS from Admin site will be make under
            // the employee name of 'Portal'. This is to avoid having to synched 2 different systems
            // users may exist in the admin site but not in ITRIS.
            string empId = this.GetItrisEmployeeIdFromMembershipId(new Guid("08B418E8-EDD9-452B-843D-ECC985048DD2"));

            // string empId = this.GetItrisEmployeeIdFromMembershipId(userId);
            if (empId == null)
            {
                throw new RecordNotFoundException(
                          string.Format("Cannot insert to ITRIS as could not find correct EMP_ID to use for user {0}", userId));
            }

            this.associateRepo.InsertAssociateToItris(this.dataMapper.MapAssociateM2E(associate), empId);
        }
Exemplo n.º 11
0
        public void UpdateReferenceAdminEventHistoryForAssociate(AssociateModel associate)
        {
            foreach (ReferenceBaseModel reference in associate.References)
            {
                reference.AdministrativeEventsForReference = this.associateRefRepo.GetAdministrativeEventsForReference(reference.Id);

                var referenceWithAccountants = reference as IReferenceWithAccountants;
                if (referenceWithAccountants != null)
                {
                    foreach (ReferenceAccountantModel accountant in referenceWithAccountants.Accountants)
                    {
                        accountant.AdministrativeEventsForReference = this.associateRefRepo.GetAdministrativeEventsForReference(accountant.Id);
                    }
                }
            }

            associate.UpdateJson();
        }
Exemplo n.º 12
0
        private void UpdateAssociateToItris(AssociateModel associate, Guid userId)
        {
            if (associate.ITRISAppId == null)
            {
                this.InsertAssociateToItris(associate, userId);
            }
            else
            {
                string empId = this.GetItrisEmployeeIdFromMembershipId(userId);

                if (empId == null)
                {
                    throw new RecordNotFoundException(
                              string.Format("Cannot update to ITRIS as could not find correct EMP_ID to use for user {0}", userId));
                }

                this.associateRepo.UpdateAssociateToItris(this.dataMapper.MapAssociateM2E(associate), empId);
            }
        }
Exemplo n.º 13
0
 public void UpdateAssociateToITRIS(AssociateModel associate, Guid currentUserId)
 {
     if (Settings.Default.UseTransactionScopeForItris)
     {
         using (var scope = new TransactionScope(
                    TransactionScopeOption.Required,
                    new TransactionOptions {
             IsolationLevel = IsolationLevel.ReadCommitted
         }))
         {
             this.UpdateAssociateToItris(associate, currentUserId);
             scope.Complete();
         }
     }
     else
     {
         this.UpdateAssociateToItris(associate, currentUserId);
     }
 }
Exemplo n.º 14
0
        public HttpResponseMessage AddAssociate([FromBody] AssociateModel assocaite)
        {
            AssociateModel result = new AssociateModel();

            try
            {
                var alreadyExists = _associatesService.GetAssociate(assocaite.Associate_Id);
                if (alreadyExists == null)
                {
                    var input = Helper.CastObject <Associate>(assocaite);
                    var res   = _associatesService.CreateAssociate(input);
                    result = Helper.CastObject <AssociateModel>(res);
                }
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(result));
        }
Exemplo n.º 15
0
        public void DeleteAssociateTest()
        {
            var associate           = _associatesService.GetAllAssociates().Where(a => a.Associate_Id == 575566).FirstOrDefault();
            var response            = new AssociateModel();
            var request             = Helper.CastObject <AssociateModel>(associate);
            var associateController = new AssociateController(_associatesService, _logManager)
            {
                Request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(ServiceBaseURL + "associate/deleteAssociate")
                }
            };

            associateController.Configuration = new HttpConfiguration();
            _response = associateController.DeleteAssociate(request);
            response  = JsonConvert.DeserializeObject <AssociateModel>(_response.Content.ReadAsStringAsync().Result);
            Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(response != null, true);
        }
Exemplo n.º 16
0
        public void GetAssociateTest()
        {
            var request = new AssociateModel
            {
                Associate_Id = 579946
            };
            var response            = new AssociateModel();
            var associateController = new AssociateController(_associatesService, _logManager)
            {
                Request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(ServiceBaseURL + "associate/getAssociate")
                }
            };

            associateController.Configuration = new HttpConfiguration();
            _response = associateController.GetAssociate(request);
            response  = JsonConvert.DeserializeObject <AssociateModel>(_response.Content.ReadAsStringAsync().Result);
            Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(response != null, true);
        }
Exemplo n.º 17
0
        private static void GetReferenceDocumentsToDeleteOrRestore(
            AssociateModel associate,
            List <Guid> documentsToRestore,
            List <Guid> documentsToDelete)
        {
            foreach (var reference in associate.References)
            {
                if (reference is IReferenceWithDocuments)
                {
                    ProcessReferenceDocuments(documentsToDelete, documentsToRestore, reference);
                }

                var referenceWithAccountants = reference as IReferenceWithAccountants;
                if (referenceWithAccountants != null)
                {
                    foreach (var accountant in referenceWithAccountants.Accountants)
                    {
                        ProcessReferenceDocuments(documentsToDelete, documentsToRestore, accountant);
                    }
                }
            }
        }
Exemplo n.º 18
0
        public JsonResult ApproveTimesheet(TimesheetViewModel model, int?roleId = null)
        {
            bool           result;
            AssociateModel currentUserId = null;

            try
            {
                currentUserId = associateService.GetAssociate(User.Identity.Name);
            }
            catch (Exception) {}

            if (currentUserId == null || currentUserId.Id == 0)
            {
                model.CurrentUserId = this.ClientContactVerifiedDetails().ClientContactId;
                result = timesheetService.ApproveTimesheet(model, true);
            }
            else
            {
                result = timesheetService.ApproveTimesheet(model);
            }
            return(Json(result));
        }
Exemplo n.º 19
0
 public string AddAssociateDetails(AssociateModel associateDetails)
 {
     return(associateBusiness.AddAssociateDetails(associateDetails));
 }
Exemplo n.º 20
0
 public void ApproveAssociate(AssociateModel associate)
 {
     this.associateRepo.UpdateAssociateStatus(associate.Id, AssociateApprovalStatus.Approved);
 }
Exemplo n.º 21
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
                }
            });
        }
Exemplo n.º 22
0
 public AssosciateResult Post(AssociateModel oAsso)
 {
     return(oBusines.UpdateAssociate(oAsso));
 }
Exemplo n.º 23
0
 public Status DeleteUser(AssociateModel oAsso)
 {
     return(oBusines.DeleteAssociate(oAsso));
 }