Пример #1
0
 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
     {
         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);
     }
 }
Пример #5
0
 public HRJobTitle ToJobTitle()
 {
     HRJobTitle et = new HRJobTitle();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
Пример #6
0
 public ImportSession ToImportSession()
 {
     ImportSession s = new ImportSession();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(s);
     return s;
 }
Пример #7
0
        public void GetCrudStatus(Infrastructure.LcpsDbContext context)
        {
            CrudStatus = ImportCrudStatus.None;

            // ---------- Validate Staff
            HRStaff staff = context.StaffMembers.FirstOrDefault(x => x.StaffId.ToLower() == this.StaffId.ToLower());
            if (staff == null)
                CrudStatus = ImportCrudStatus.InsertMember | ImportCrudStatus.CreateMembership;
            else
            {
                if(staff.LastName == "Stanislas")
                {
                    int z = 0;
                    z++;
                }
                AnvilEntity sm = new AnvilEntity(this);
                sm.CompareFields.Add("StaffId");
                sm.CompareFields.Add("FirstName");
                sm.CompareFields.Add("MiddleInitial");
                sm.CompareFields.Add("LastName");
                sm.CompareFields.Add("Birthdate");
                sm.CompareFields.Add("Gender");
                sm.Compare(staff);

                if (sm.Compare(staff).Count() > 0)
                    CrudStatus = CrudStatus | ImportCrudStatus.UpdateMember;

            }

            if (staff != null)
            {

                // ------- Vadlidate Position
                HRStaffPosition position = context.StaffPositions
                    .FirstOrDefault(x =>
                        x.StaffMemberId.Equals(staff.StaffKey)
                        & x.BuildingKey.Equals(_staffDefinition.Building.BuildingKey)
                        & x.EmployeeTypeKey.Equals(_staffDefinition.EmployeeType.EmployeeTypeLinkId)
                        & x.JobTitleKey.Equals(_staffDefinition.JobTitle.JobTitleKey));

                if (position == null)
                    CrudStatus = CrudStatus | ImportCrudStatus.CreateMembership;
                else
                {
                    AnvilEntity pm = new AnvilEntity(this);
                    pm.CompareFields.Add("FiscalYear");
                    pm.CompareFields.Add("Status");
                    if (pm.Compare(position).Count() > 0)
                        CrudStatus = CrudStatus | ImportCrudStatus.UpdateMembership;
                }
            }
        }
Пример #8
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();
 }
Пример #9
0
 public ImportItem ToImportItem()
 {
     ImportItem i = new ImportItem();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(i);
     return i;
 }
 public InstructionalLevel ToInstructionalLevel()
 {
     InstructionalLevel et = new InstructionalLevel();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
Пример #11
0
 public bool IsSyncJustified()
 {
     AnvilEntity e = new AnvilEntity(this);
     HRBuilding b = db.Buildings.First(x => x.BuildingId == this.BuildingId);
     return (e.Compare(b).Count() > 0);
 }
Пример #12
0
 public bool IsSyncJustified()
 {
     AnvilEntity e = new AnvilEntity(this);
     HREmployeeType jt = db.EmployeeTypes.First(x => x.EmployeeTypeId == this.EmployeeTypeId);
     return (e.Compare(jt).Count() > 0);
 }
Пример #13
0
 public HRStaff ToStaff()
 {
     HRStaff b = new HRStaff();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(b);
     return b;
 }
Пример #14
0
 public bool IsSyncJustified()
 {
     AnvilEntity e = new AnvilEntity(this);
     HRStaff b = db.StaffMembers.First(x => x.StaffKey == this.StaffKey);
     return (e.Compare(b).Count() > 0);
 }
        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();
        }
Пример #16
0
 public StaffFilterClauseModel(StaffFilterClause c)
 {
     AnvilEntity e = new AnvilEntity(c);
     e.CopyTo(this);
 }
Пример #17
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);
     }
 }
Пример #18
0
 public HREmployeeType ToEmployeeType()
 {
     HREmployeeType et = new HREmployeeType();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
 public bool IsSyncJustified()
 {
     InstructionalLevel i = ToInstructionalLevel();
     InstructionalLevel t = DbContext.InstructionalLevels.First(x => x.InstructionalLevelId == this.InstructionalLevelId);
     AnvilEntity e = new AnvilEntity(i);
     return (e.Compare(t).Count() > 0);
 }
Пример #20
0
 public HRBuilding ToBuilding()
 {
     HRBuilding b = new HRBuilding();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(b);
     return b;
 }
Пример #21
0
        public void Validate(Infrastructure.LcpsDbContext context)
        {
            // ---------- Vadliate User key
            HRStaff staff = context.StaffMembers.FirstOrDefault(x => x.StaffId.ToLower() == this.EntityId.ToLower());
            if (staff == null)
            {
                Student stu = context.Students.FirstOrDefault(x => x.StudentId.ToLower() == this.EntityId.ToLower());
                if (stu == null)
                {
                    ValidationReport = string.Format("{0} is not a valida student or staff id", this.EntityId);
                    ValidationStatus = ImportRecordStatus.danger;
                    return;
                }
                else
                    _userKey = stu.StudentKey;

            }
            else _userKey = staff.StaffKey;

            // ---------- Validate Fields
            try
            {
                AnvilEntity e = new AnvilEntity(this);
                e.RequiredFields.Add("StaffId");
                e.RequiredFields.Add("UserName");
                e.RequiredFields.Add("Password");
                e.Validate();
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector(ex);
                ValidationReport = ec.ToLineBreakString();
                ValidationStatus = ImportRecordStatus.danger;
                return;
            }

            // ---------- Validate Password
            if(this.Password.Length < 6)
            {
                ValidationReport = "The password must contain at least 6 characters";
                ValidationStatus = ImportRecordStatus.danger;
                return;
            }

            ValidationReport = "Validated";
            ValidationStatus = ImportRecordStatus.success;
        }
Пример #22
0
 public bool IsSyncJustified()
 {
     Student s = ToStudent();
     Student t = DbContext.Students.First(x => x.StudentId == this.StudentId);
     AnvilEntity e = new AnvilEntity(s);
     return (e.Compare(t)).Count() > 0;
 }
Пример #23
0
        public void GetCrudStatus(Infrastructure.LcpsDbContext context)
        {
            CrudStatus = ImportCrudStatus.None;

            LdapAccount ac = context.LdapAccounts
                .FirstOrDefault(
                    x => x.UserKey.Equals(_userKey)
                    & x.UserName.ToLower() == this.UserName.ToLower()
                );

            if (ac == null)
                CrudStatus = ImportCrudStatus.InsertMember;
            else
            {
                AnvilEntity e = new AnvilEntity(this);
                e.CompareFields.Add("Active");
                if(e.Compare(ac).Count() > 0)
                    CrudStatus = ImportCrudStatus.UpdateMembership;
            }
        }
Пример #24
0
 public Student ToStudent()
 {
     Student et = new Student();
     AnvilEntity e = new AnvilEntity(this);
     e.CopyTo(et);
     return et;
 }
Пример #25
0
 public MemberFilterModel(MemberFilter f)
 {
     AnvilEntity e = new AnvilEntity(f);
     e.CopyTo(this);
 }
Пример #26
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 });
        }
Пример #27
0
 public bool IsSyncJustified()
 {
     AnvilEntity e = new AnvilEntity(this);
     HRJobTitle jt = db.JobTitles.First(x => x.JobTitleId == this.JobTitleId);
     return (e.Compare(jt).Count() > 0);
 }
Пример #28
0
        public void Validate(Infrastructure.LcpsDbContext context)
        {
            // ---------- Validate Position Info

            try
            {
                _staffDefinition = new HRStaffPositionDefinition(this.BuildingId, this.EmployeeTypeId, this.JobTitleId, context);
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector(ex);
                ValidationReport = ec.ToLineBreakString();
                ValidationStatus = ImportRecordStatus.danger;
                return;
            }

            // ---------- Valdiate Birthdate
            try
            {
                DateTime d = this.Birthdate;
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector(new Exception("Invalid bithdate", ex));
                ValidationReport = ec.ToLineBreakString();
                ValidationStatus = ImportRecordStatus.danger;
                return;
            }

            // ---------- Valdiate Status Qualifier
            try
            {
                HRStaffPositionQualifier q = this.Status;
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector(new Exception("Invalid status", ex));
                ValidationReport = ec.ToLineBreakString();
                ValidationStatus = ImportRecordStatus.danger;
                return;
            }

            // ---------- Validate gender
            try
            {
                HRGenders g = this.Gender;
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector(new Exception("Invalid gender", ex));
                ValidationReport = ec.ToLineBreakString();
                ValidationStatus = ImportRecordStatus.danger;
                return;
            }

            // --------- Validate Required fields
            try
            {
                AnvilEntity e = new AnvilEntity(this);
                e.RequiredFields.Add("StaffId");
                e.RequiredFields.Add("FirstName");
                e.RequiredFields.Add("LastName");

                e.Validate();
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector(ex);
                ValidationReport = ec.ToLineBreakString();
                ValidationStatus = ImportRecordStatus.danger;
                return;

            }

            ValidationStatus = ImportRecordStatus.success;
            ValidationReport = "Validated";
        }
Пример #29
0
 public ImportFileTSV(ImportSession s)
 {
     AnvilEntity e = new AnvilEntity(s);
     e.CopyTo(this);
     Delimiter = '\t'.ToString();
 }