Exemplo n.º 1
0
        public EducationVO Save(EducationVO model)
        {
            MemberState state = MemberStateBL.State;

            try
            {
                model.MemberId = state.Member.Id;
                bool success = int.TryParse(model.GraduationYear, out int graduationYear);
                success = int.TryParse(model.StartYear, out int startYear);
                if (success)
                {
                    if (graduationYear < startYear)
                    {
                        throw new Exception(Resource.Er0009);
                    }
                }
                else
                {
                    throw new Exception(Resource.ErSomethingWrong);
                }
                // Insert new Education
                if (model.Id == 0)
                {
                    model.CreatedDate  = DateTime.UtcNow;
                    model.ModifiedDate = null;
                    using (var ctx = new EducationContext())
                    {
                        IEducationDA da = new EducationDA();
                        model = da.Insert(ctx, model);
                    }
                }
                // Update Education
                else
                {
                    model.ModifiedDate = TimeZone.CurrentTimeZone.ToLocalTime(DateTime.Now);
                    using (var ctx = new EducationContext())
                    {
                        IEducationDA da = new EducationDA();
                        da.Update(ctx, model);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get Member's educations async
        /// </summary>
        /// <param name="memberId"></param>
        /// <returns></returns>
        public List <EducationVO> GetEducationsByMemberId(int memberId)
        {
            List <EducationVO> model = new List <EducationVO>();

            try
            {
                using (var ctx = new EducationContext())
                {
                    IEducationDA da = new EducationDA();
                    model = da.FindEducationsByMemberId(memberId, ctx);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(model);
        }
Exemplo n.º 3
0
        public EducationVO GetEducationById(int id)
        {
            MemberState state = MemberStateBL.State;
            EducationVO model = new EducationVO();

            try
            {
                using (var ctx = new EducationContext())
                {
                    IEducationDA da = new EducationDA();
                    model = da.FindEducationById(id, ctx);
                    if (model.MemberId != state.Member.Id)
                    {
                        throw new AuthenticationException();
                    }
                }
            }
            catch
            {
                throw;
            }
            return(model);
        }