/// <summary> /// Saves the staff. /// </summary> /// <param name="staff">The staff.</param> /// <param name="createdOrModifiedBy">The created or modified by.</param> /// <returns></returns> public IStaff SaveStaff(IStaff staff, string createdOrModifiedBy) { try { using (var context = GetUnPersistedDataContext()) { Staff staffToSave = null; if (staff.StaffID == 0) { staffToSave = new Staff(); staffToSave.CreatedBy = createdOrModifiedBy; } else { staffToSave = context.Staffs.SingleOrDefault(s => s.StaffID == staff.StaffID); } if (staffToSave != default(Staff)) { staffToSave.InitialName = staff.InitialName; staffToSave.FirstName = staff.FirstName; staffToSave.LastName = staff.LastName; staffToSave.DateofBirth = staff.DateofBirth; staffToSave.Gender = staff.Gender; staffToSave.PostCode = staff.PostCode; staffToSave.Address = staff.Address; staffToSave.Province = staff.Province; staffToSave.PhoneNo = staff.PhoneNo; staffToSave.IsDeleted = staff.IsDeleted; staffToSave.UserGuid = staff.UserGuid; } if (staff.StaffID <= 0) { context.Staffs.InsertOnSubmit(staffToSave); } else { staffToSave.ModifiedBy = createdOrModifiedBy; } context.SubmitChanges(); return (IStaff)staffToSave; } } catch { throw; } }
partial void UpdateStaff(Staff instance);
partial void DeleteStaff(Staff instance);
partial void InsertStaff(Staff instance);