コード例 #1
0
        /// <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;
            }
        }
コード例 #2
0
 partial void UpdateStaff(Staff instance);
コード例 #3
0
 partial void DeleteStaff(Staff instance);
コード例 #4
0
 partial void InsertStaff(Staff instance);