Пример #1
0
        /// <summary>
        /// Deletes the children information.
        /// </summary>
        /// <param name="information">The information.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// information
        /// or
        /// ChildrenInfo
        /// </exception>
        public string DeleteChildrenInformation(IChildrenInformationView information)
        {
            var result = string.Empty;

            if (information == null)
            {
                throw new ArgumentNullException(nameof(information));
            }
            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var ChildrenInfo = dbContext.Children.SingleOrDefault(x => x.ChildrenId == information.ChildrenId);

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

                    ChildrenInfo.IsActive = false;

                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("EditChildrenInformation - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }
            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="childrenInformation"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public IChildrenInformationView CreateChildrenInformation(IChildrenInformationView childrenInformation, string message)
        {
            if (childrenInformation == null)
            {
                throw new ArgumentNullException(nameof(childrenInformation));
            }


            childrenInformation.ProcessingMessage = string.Empty;
            return(childrenInformation);
        }
Пример #3
0
        /// <summary>
        /// Edits the children information.
        /// </summary>
        /// <param name="information">The information.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// information
        /// or
        /// ChildrenInfo
        /// </exception>
        public string EditChildrenInformation(IChildrenInformationView information)
        {
            var result = string.Empty;

            if (information == null)
            {
                throw new ArgumentNullException(nameof(information));
            }
            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var ChildrenInfo = dbContext.Children.SingleOrDefault(x => x.ChildrenId == information.ChildrenId);

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

                    ChildrenInfo.EmployeeId   = information.EmployeeId;
                    ChildrenInfo.Address      = information.Address;
                    ChildrenInfo.Email        = information.Email;
                    ChildrenInfo.Mobile       = information.Mobile;
                    ChildrenInfo.DateOfBirth  = information.DateOfBirth;
                    ChildrenInfo.DateCreated  = information.DateCreated;
                    ChildrenInfo.DateModified = DateTime.Now;
                    ChildrenInfo.IsApproved   = false;
                    ChildrenInfo.ChildName    = information.ChildName;
                    ChildrenInfo.IsActive     = true;

                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("EditChildrenInformation - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Saves the children information.
        /// </summary>
        /// <param name="children">The children.</param>
        /// <returns></returns>
        public string SaveChildrenInformation(IChildrenInformationView children)
        {
            var result = string.Empty;

            var view = new Child
            {
                EmployeeId   = children.EmployeeId,
                Address      = children.Address,
                Email        = children.Email,
                Mobile       = children.Mobile,
                DateOfBirth  = children.DateOfBirth,
                DateCreated  = DateTime.Now,
                IsApproved   = false,
                ChildName    = children.ChildName,
                DateModified = DateTime.UtcNow,
                IsActive     = true
            };

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


            return(result);
        }