Ejemplo n.º 1
0
        public Faculty AddFaculty(Faculty FacultyObj)
        {
            try
            {
                Faculty faculty = _context.Faculties.Where(x => x.Name == FacultyObj.Name).FirstOrDefault();
                if (faculty == null)
                {
                    faculty.CreatedDate = DateTime.Now;
                    faculty.ModifiedDate = DateTime.Now;
                    _context.Faculties.Add(FacultyObj);
                    _context.SaveChangesAsync();
                    return faculty;
                }
                return null;
            }
            catch (Exception)
            {

                throw;
            }
        }
Ejemplo n.º 2
0
        public bool UpdateFaculty(Faculty FacultyObj)
        {
            try
            {
                Faculty faculty = _context.Faculties.Where(x => x.FacultyId == FacultyObj.FacultyId).FirstOrDefault();
                if (faculty != null)
                {
                    faculty.Name = FacultyObj.Name;
                    faculty.Address = FacultyObj.Address;
                    faculty.City = FacultyObj.City;
                    faculty.Country = FacultyObj.Country;
                    faculty.Department = FacultyObj.Department;
                    faculty.Designation = FacultyObj.Designation;
                    faculty.DOB = FacultyObj.DOB;
                    faculty.Education = FacultyObj.Education;
                    faculty.EducationType = FacultyObj.EducationType;
                    faculty.Email = FacultyObj.Email;
                    faculty.Gender = FacultyObj.Gender;
                    faculty.HomeContact = FacultyObj.HomeContact;
                    faculty.JobType = FacultyObj.JobType;
                    faculty.JoiningDate = FacultyObj.JoiningDate;
                    faculty.ModifiedDate = DateTime.Now;
                    faculty.PermanentAddress = FacultyObj.PermanentAddress;
                    faculty.PermanentCity = FacultyObj.PermanentCity;
                    faculty.PermanentPostalCode = FacultyObj.PermanentPostalCode;
                    faculty.PermanentState = FacultyObj.PermanentState;
                    faculty.PersonalContact = FacultyObj.PersonalContact;
                    faculty.PostalCode = FacultyObj.PostalCode;
                    faculty.SO = FacultyObj.SO;
                    faculty.State = FacultyObj.State;
                    _context.Entry(faculty).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChangesAsync();
                    return true;
                }
                return false;
            }
            catch (Exception)
            {

                throw;
            }
        }