Esempio n. 1
0
        public EducationVO FindEducationById(int id, EducationContext ctx)
        {
            EducationVO model = new EducationVO();

            try
            {
                var query = (from edu in ctx.Educations.AsEnumerable()
                             where edu.Id == id
                             select new EducationVO
                {
                    Id = edu.Id,
                    MemberId = edu.MemberId,
                    Degree = edu.Degree,
                    School = edu.School,
                    Department = edu.Department,
                    StartYear = edu.StartYear,
                    GraduationYear = edu.GraduationYear,
                    Grade = edu.Grade
                }).Single();

                model.Id             = FillItemForDatabase.FillItem(query.Id);
                model.MemberId       = FillItemForDatabase.FillItem(query.MemberId);
                model.Degree         = FillItemForDatabase.FillItem(query.Degree);
                model.School         = FillItemForDatabase.FillItem(query.School);
                model.Department     = FillItemForDatabase.FillItem(query.Department);
                model.StartYear      = FillItemForDatabase.FillItem(query.StartYear);
                model.GraduationYear = FillItemForDatabase.FillItem(query.GraduationYear);
                model.Grade          = FillItemForDatabase.FillItem(query.Grade);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(model);
        }
Esempio n. 2
0
        public ActionResult EducationEdit(int id)
        {
            MemberState state = MemberStateBL.State;
            EducationVO model = new EducationVO();

            try
            {
                IEducationBL bl = new EducationBL();
                model = bl.GetEducationById(id);
                if (model.MemberId != state.Member.Id)
                {
                    throw new AuthenticationException(Resource.NotAuthorized);
                }
                EducationCreateViewBag();
                return(PartialView("_EducationEdit", model));
            }
            catch (AuthenticationException ex)
            {
                TempData["UIMsg"] = new UIMessage(ex.Message, eUIMsgType.danger);
                return(Json(new { error = true, message = ex.Message }));
            }
            catch (Exception ex)
            {
                TempData["UIMsg"] = new UIMessage(ex.Message, eUIMsgType.danger);
                return(Json(new { error = true, message = ex.Message }));
            }
        }
Esempio n. 3
0
 public EducationVO Insert(EducationContext ctx, EducationVO model)
 {
     try
     {
         ctx.Educations.Add(model);
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(model);
 }
Esempio n. 4
0
 public ActionResult UpdateEducation(EducationVO model, FormCollection collection)
 {
     try
     {
         IEducationBL bl = new EducationBL();
         bl.Save(model);
     }
     catch (Exception ex)
     {
         TempData["UIMsg"] = new UIMessage(ex.Message, eUIMsgType.danger);
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 5
0
 public void Update(EducationContext ctx, EducationVO model)
 {
     try
     {
         ctx.Entry(model).State = EntityState.Modified;
         ctx.Educations.Attach(model);
         ctx = UpdateProperties(model, ctx);
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
 public ActionResult EducationCreate(EducationVO model, FormCollection collection)
 {
     try
     {
         model.Grade = Decimal.Parse(collection["Grade"].Replace(".", ","));
         model       = new EducationBL().Save(model);
     }
     catch (Exception ex)
     {
         TempData["UIMsg"] = new UIMessage(ex.Message, eUIMsgType.danger);
         return(RedirectToAction("Index"));
     }
     TempData["UIMsg"] = new UIMessage(Resource.M0003, eUIMsgType.success);
     return(RedirectToAction("Index"));
 }
Esempio n. 7
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);
        }
Esempio n. 8
0
 private EducationContext UpdateProperties(EducationVO model, EducationContext ctx)
 {
     try
     {
         ctx.Entry(model).Property("Degree").IsModified         = UpdateItemToDatabasecs.Item(model.Degree);
         ctx.Entry(model).Property("School").IsModified         = UpdateItemToDatabasecs.Item(model.School);
         ctx.Entry(model).Property("Department").IsModified     = UpdateItemToDatabasecs.Item(model.Department);
         ctx.Entry(model).Property("Grade").IsModified          = UpdateItemToDatabasecs.Item(model.Grade);
         ctx.Entry(model).Property("StartYear").IsModified      = UpdateItemToDatabasecs.Item(model.StartYear);
         ctx.Entry(model).Property("GraduationYear").IsModified = UpdateItemToDatabasecs.Item(model.GraduationYear);
         ctx.Entry(model).Property("CreatedDate").IsModified    = UpdateItemToDatabasecs.Item(model.CreatedDate);
         ctx.Entry(model).Property("MemberId").IsModified       = UpdateItemToDatabasecs.Item(model.MemberId);
         ctx.Entry(model).Property("ModifiedDate").IsModified   = UpdateItemToDatabasecs.Item(model.ModifiedDate);
     }
     catch
     {
         throw;
     }
     return(ctx);
 }
Esempio n. 9
0
        /// <summary>
        /// Create new Studies
        /// </summary>
        /// <returns></returns>
        public ActionResult EducationCreate()
        {
            MemberState state = MemberStateBL.State;
            EducationVO model = new EducationVO();

            try
            {
                model.MemberId = state.Member.Id;
                model.Member   = state.Member;

                ViewBag.Path = true;
                Path path = new Path();
                path.InsertMainItemToPath((byte)eMain.Cv);
                //path.InsertItemToPath((byte)eMain.Cv, Resource.StudiesCreate, "Create");
                path.CreateSessionPath();
            }
            catch
            {
            }
            return(PartialView("_EducationCreate", model));
        }
Esempio n. 10
0
        public List <EducationVO> FindEducationsByMemberId(int memberId, EducationContext ctx)
        {
            List <EducationVO> model = new List <EducationVO>();

            try
            {
                var query = (from edu in ctx.Educations.AsEnumerable()
                             where edu.MemberId == memberId
                             select new EducationVO
                {
                    Id = edu.Id,
                    Degree = edu.Degree,
                    School = edu.School,
                    Department = edu.Department,
                    StartYear = edu.StartYear,
                    GraduationYear = edu.GraduationYear,
                    Grade = edu.Grade
                }).ToList();

                foreach (EducationVO edu in query)
                {
                    EducationVO education = new EducationVO()
                    {
                        Id             = FillItemForDatabase.FillItem(edu.Id),
                        Degree         = FillItemForDatabase.FillItem(edu.Degree),
                        School         = FillItemForDatabase.FillItem(edu.School),
                        Department     = FillItemForDatabase.FillItem(edu.Department),
                        StartYear      = FillItemForDatabase.FillItem(edu.StartYear),
                        GraduationYear = FillItemForDatabase.FillItem(edu.GraduationYear),
                        Grade          = FillItemForDatabase.FillItem(edu.Grade),
                    };
                    model.Add(education);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(model);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
 public void Save_NullOperations(EducationVO model)
 {
 }