/// <summary>
        ///
        /// </summary>
        /// <param name="beneficiaries"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public IBeneficiariesView CreateBeneficiaries(IBeneficiariesView beneficiaries, string message)
        {
            if (beneficiaries == null)
            {
                throw new ArgumentNullException(nameof(beneficiaries));
            }


            beneficiaries.ProcessingMessage = string.Empty;
            return(beneficiaries);
        }
Beispiel #2
0
        /// <summary>
        /// Edits the beneficiaries.
        /// </summary>
        /// <param name="beneficiaries">The beneficiaries.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// beneficiaries
        /// or
        /// Beneficiaries
        /// </exception>
        public string EditBeneficiaries(IBeneficiariesView beneficiaries)
        {
            var result = string.Empty;

            if (beneficiaries == null)
            {
                throw new ArgumentNullException(nameof(beneficiaries));
            }
            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var Beneficiaries = dbContext.Beneficiaries.SingleOrDefault(x => x.BeneficiaryId == beneficiaries.BeneficiaryId);

                    if (Beneficiaries == null)
                    {
                        throw new ArgumentNullException(nameof(Beneficiaries));
                    }

                    Beneficiaries.Address         = beneficiaries.Address;
                    Beneficiaries.Email           = beneficiaries.Email;
                    Beneficiaries.Mobile          = beneficiaries.Mobile;
                    Beneficiaries.DateOfBirth     = beneficiaries.DateOfBirth;
                    Beneficiaries.DateModified    = DateTime.Now;
                    Beneficiaries.IsApproved      = false;
                    Beneficiaries.BeneficiaryName = beneficiaries.BeneficiaryName;

                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("EditBeneficiaries - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Saves the beneficiaries.
        /// </summary>
        /// <param name="beneficiaries">The beneficiaries.</param>
        /// <returns></returns>
        public string SaveBeneficiaries(IBeneficiariesView beneficiaries)
        {
            var result = string.Empty;

            var view = new Beneficiary
            {
                EmployeeId      = beneficiaries.EmployeeId,
                Address         = beneficiaries.Address,
                Email           = beneficiaries.Email,
                Mobile          = beneficiaries.Mobile,
                DateOfBirth     = beneficiaries.DateOfBirth,
                DateCreated     = DateTime.Now,
                IsApproved      = false,
                BeneficiaryName = beneficiaries.BeneficiaryName,
                DateModified    = DateTime.UtcNow,
                IsActive        = true
            };

            try
            {
                // calling our database
                using (var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    // calling changes
                    dbContext.Beneficiaries.Add(view);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("view - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }


            return(result);
        }