Beispiel #1
0
 public Guid Add(Employee entity)
 {
     using (OpenPOSDbEntities ctx = new OpenPOSDbEntities())
     {
         try
         {
             ctx.Employees.AddObject(entity);
             ctx.SaveChanges();
             return entity.Id;
         }
         catch (Exception ex)
         {
             LogService.Error("Error while adding Employee", ex);
             throw new ArgumentException("Error while adding new Employee!");
         }
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEmployees(Employee employee)
 {
     base.AddObject("Employees", employee);
 }
Beispiel #3
0
        public void Update(Employee entity)
        {
            if (entity.Id.Equals(Guid.Empty))
                throw new ArgumentException("Employee Id cannot be empty!");

            using (OpenPOSDbEntities ctx = new OpenPOSDbEntities())
            {
               try
                {

                    ctx.Employees.Attach(entity);

                    ctx.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified);

                    ctx.Employees.ApplyCurrentValues(entity);

                    ctx.SaveChanges();

                }
                catch (Exception ex)
                {
                    LogService.Error("Error while updating Employee", ex);
                    throw ex;
                }
            }
        }
 /// <summary>
 /// Create a new Employee object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="contactDetailId">Initial value of the ContactDetailId property.</param>
 /// <param name="dateOfJoining">Initial value of the DateOfJoining property.</param>
 /// <param name="salary">Initial value of the Salary property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static Employee CreateEmployee(global::System.Guid id, global::System.Guid contactDetailId, global::System.DateTime dateOfJoining, global::System.Double salary, global::System.Boolean status)
 {
     Employee employee = new Employee();
     employee.Id = id;
     employee.ContactDetailId = contactDetailId;
     employee.DateOfJoining = dateOfJoining;
     employee.Salary = salary;
     employee.Status = status;
     return employee;
 }