public StaffFilterClause ToFilterClause()
 {
     AnvilEntity e = new AnvilEntity(this);
     StaffFilterClause c = new StaffFilterClause();
     e.CopyTo(c);
     return c;
 }
示例#2
0
 public HRStaff(Guid staffLinkId)
 {
     HRStaff dbStaff = db.StaffMembers.FirstOrDefault(x => x.StaffKey.Equals(staffLinkId));
     if (dbStaff != null)
     {
         AnvilEntity e = new AnvilEntity(dbStaff);
         e.CopyTo(this);
     }
 }
示例#3
0
        public StudentDetailModel(Guid id)
        {
            StudentRecord stu = _studentContext.StudentRecords.FirstOrDefault(x => x.StudentKey.Equals(id));
            if (stu == null)
                throw new Exception(string.Format("No student with key {0} could be found in the database", id.ToString()));

            AnvilEntity e = new AnvilEntity(stu);
            e.CopyTo(this);
        }
示例#4
0
 public void Update()
 {
     try
     {
         HRBuilding b = db.Buildings.First(x => x.BuildingKey.Equals(this.BuildingKey));
         AnvilEntity e = new AnvilEntity(this);
         e.CopyTo(b);
         db.Entry(b).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("Could not update job title", ex);
     }
 }
示例#5
0
 public HRBuilding ToBuilding()
 {
     HRBuilding b = new HRBuilding();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(b);
     return b;
 }
 public StaffFilterClauseModel(StaffFilterClause c)
 {
     AnvilEntity e = new AnvilEntity(c);
     e.CopyTo(this);
 }
示例#7
0
 public void Update()
 {
     try
     {
         HRJobTitle jt = db.JobTitles.First(x => x.JobTitleKey.Equals(this.JobTitleKey));
         AnvilEntity e = new AnvilEntity(this);
         e.CopyTo(jt);
         db.Entry(jt).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("Could not update job title", ex);
     }
 }
示例#8
0
 public ImportSession ToImportSession()
 {
     ImportSession s = new ImportSession();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(s);
     return s;
 }
示例#9
0
 public void Update()
 {
     Student s = ToStudent();
     Student t = DbContext.Students.First(x => x.StudentId == this.StudentId);
     AnvilEntity e = new AnvilEntity(s);
     e.CopyTo(t);
     DbContext.Entry(t).State = System.Data.Entity.EntityState.Modified;
     DbContext.SaveChanges();
 }
 public HREmployeeType ToEmployeeType()
 {
     HREmployeeType et = new HREmployeeType();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
示例#11
0
 public HRStaff ToStaff()
 {
     HRStaff b = new HRStaff();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(b);
     return b;
 }
        public void Update()
        {
            InstructionalLevel i = ToInstructionalLevel();
            InstructionalLevel t = DbContext.InstructionalLevels.First(x => x.InstructionalLevelId == this.InstructionalLevelId);
            AnvilEntity e = new AnvilEntity(i);
            e.CopyTo(t);

            DbContext.Entry(t).State = System.Data.Entity.EntityState.Modified;
            DbContext.SaveChanges();
        }
 public InstructionalLevel ToInstructionalLevel()
 {
     InstructionalLevel et = new InstructionalLevel();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
示例#14
0
 public ImportItem ToImportItem()
 {
     ImportItem i = new ImportItem();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(i);
     return i;
 }
示例#15
0
 public MemberFilterModel(MemberFilter f)
 {
     AnvilEntity e = new AnvilEntity(f);
     e.CopyTo(this);
 }
示例#16
0
 public Student ToStudent()
 {
     Student et = new Student();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
示例#17
0
 public HRJobTitle ToJobTitle()
 {
     HRJobTitle et = new HRJobTitle();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
示例#18
0
        public ActionResult AddStaffClause(StaffFilterClauseModel m)
        {
            if (!m.BuildingInclude & !m.EmployeeTypeInclude & !m.JobTitleInclude & !m.StatusInclude & !m.StaffIdInclude & !m.LastNameInclude)
                ModelState.AddModelError("", "Please include at least one field in the filter");

            MemberFilter f = null;

            try
            {
                f = DbContext.MemberFilters.First(x => x.FilterId.Equals(m.FilterId));
            }
            catch
            {
                ModelState.AddModelError("", "Invalid filter id");
            }

            int count = DbContext.StaffFilterClauses.Where(x => x.FilterId.Equals(m.FilterId)).Count();

            bool hasErrors = ViewData.ModelState.Values.Any(x => x.Errors.Count > 1);
            List<ModelState> errors = ViewData.ModelState.Values.Where(x => x.Errors.Count() > 0).ToList();

            if (ModelState.IsValid)
            {
                try
                {
                    StaffFilterClause c = new StaffFilterClause();

                    AnvilEntity e = new AnvilEntity(m);
                    e.CopyTo(c);
                    c.StaffFilterClauseId = Guid.NewGuid();
                    c.SortIndex = count;
                    DbContext.StaffFilterClauses.Add(c);
                    DbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    return View("~/Views/Shared/Error.cshtml", new AnvilExceptionModel(ex, "Create Staff Clause", "My", "Contacts", "EditStaffFilter"));
                }
            }
            else
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector("The staff filter clause could not be validated");
                foreach (ModelState ms in errors)
                {
                    foreach (var x in ms.Errors)
                    {
                        ec.Add(x.ErrorMessage);
                    }
                }

                AnvilExceptionModel em = new AnvilExceptionModel(ec.ToException(), "Create Staff Filter Clause", null, null, null);

                MemberFilterModel fm = new MemberFilterModel(f);

                fm.Exception = em;

                return View("EditFilter", fm);
            }

            return RedirectToAction("EditFilter", new { id = m.FilterId });
        }
示例#19
0
 public ImportFileTSV(ImportSession s)
 {
     AnvilEntity e = new AnvilEntity(s);
     e.CopyTo(this);
     Delimiter = '\t'.ToString();
 }