Esempio n. 1
0
 /// <summary>
 /// Конвертация в сотрудника
 /// </summary>
 /// <param name="client">Сотрудник БД</param>
 /// <returns>Сотрудник</returns>
 public static Employee Convert(EmployeeEnt employee, bool logic = true)
 {
     if (employee != null)
     {
         List <ContactInformation> list     = null;
         PositionEmployee          position = null;
         if (logic == true)
         {
             position = Convert(employee.Position);
             list     = new List <ContactInformation>();
             foreach (var item in employee.ContactInformation)
             {
                 list.Add(Convert(item));
             }
         }
         Employee employeeEnt = new Employee
         {
             DateOfBirth        = employee.DateOfBirth,
             Commit             = employee.Commit,
             DateOfHiring       = employee.DateOfHiring,
             Id                 = employee.Id,
             LastName           = employee.LastName,
             Name               = employee.Name,
             PositionId         = employee.PositionId,
             Position           = position,
             Surname            = employee.Surname,
             ContactInformation = list
         };
         return(employeeEnt);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 2
0
        private void EditEmployee(int id, string name, DateTime hiredate, decimal salary, string deptname, string address)
        {
            EmployeeServiceClient esc = new EmployeeServiceClient();
            EmployeeEnt           e   = new EmployeeEnt();

            e.GetType().GetProperties();
            esc.EditEmployee(id, name, hiredate, salary, deptname, address);
        }
Esempio n. 3
0
 /// <summary>
 /// Конвертация в сотрудника БД
 /// </summary>
 /// <param name="client">Сотрудник</param>
 /// <returns>Сотрудник БД </returns>
 public static EmployeeEnt Convert(Employee employee)
 {
     if (employee != null)
     {
         var x = Unit.EmployeeRepository.GetItem(employee.Id);
         if (x != null)
         {
             return(x);
         }
         else
         {
             List <ContactInformationEnt> list = new List <ContactInformationEnt>();
             foreach (var item in employee.ContactInformation)
             {
                 list.Add(Convert(item));
             }
             EmployeeEnt employeeEnt = new EmployeeEnt
             {
                 DateOfBirth        = employee.DateOfBirth,
                 Commit             = employee.Commit,
                 DateOfHiring       = employee.DateOfHiring,
                 Id                 = employee.Id,
                 PositionId         = employee.PositionId,
                 LastName           = employee.LastName,
                 Name               = employee.Name,
                 Position           = Convert(employee.Position),
                 Surname            = employee.Surname,
                 ContactInformation = list
             };
             return(employeeEnt);
         }
     }
     else
     {
         return(null);
     }
 }
        protected override void Seed(StoreDbContex db)
        {
            CategoryEnt[] categories = new CategoryEnt[]
            {
                new CategoryEnt {
                    Name = "Продукты", Description = "Различные продукты"
                },
                new CategoryEnt {
                    Name = "Авто", Description = "Различные авто"
                },
                new CategoryEnt {
                    Name = "Инструменты", Description = "Инструменты"
                },
                new CategoryEnt {
                    Name = "Электроника", Description = "Телефоны, планшеты и другая электроника"
                },
            };
            db.Categories.AddRange(categories);
            db.SaveChanges();
            PositionEmployeeEnt position = new PositionEmployeeEnt {
                Name = "Менеджер", Description = "Оформляет заказы"
            };

            db.PositionEmployees.Add(position);
            db.SaveChanges();
            EmployeeEnt[] employee = new EmployeeEnt[]
            {
                new EmployeeEnt {
                    Name = "Вася", LastName = "Васильевич", PositionId = 1, Surname = "Картошкин", DateOfBirth = DateTime.Now, DateOfHiring = DateTime.Now,
                    ContactInformation = new ContactInformationEnt[] { new ContactInformationEnt {
                                                                           Phone = "+38068044452"
                                                                       } }
                },
                new EmployeeEnt {
                    Name = "Степа", LastName = "Васильевич", PositionId = 1, Surname = "Пушкин", DateOfBirth = DateTime.Now, DateOfHiring = DateTime.Now,
                    ContactInformation = new ContactInformationEnt[] { new ContactInformationEnt {
                                                                           Phone = "+380254852"
                                                                       } }
                }
            };
            db.Employees.AddRange(employee);
            db.SaveChanges();
            ClientUserEnt client = new ClientUserEnt
            {
                ContactInformation = new ContactInformationEnt[] { new ContactInformationEnt {
                                                                       Phone = "+380254885"
                                                                   } },
                Description = "Важный", Name = "Игорь", DateOfBirth = DateTime.Now, LastName = "ПЕтрович", Surname = "Годин"
            };

            db.ClientUsers.Add(client);
            db.SaveChanges();
            db.CompanyProviders.Add(new CompanyProviderEnt {
                Name = "Заказ"
            });
            db.SaveChanges();
            db.InvoiceForPurchases.Add(new InvoiceForPurchaseEnt
            {
                CompanyProviderId = 1, EmployeeId = 2, Date = DateTime.Now,
            });
            db.SalesInvoices.Add(new SalesInvoiceEnt {
                Date        = DateTime.Now,
                Description = "ЛУчшая сделка", EmployeeId = 1, ClientUserId = 1
            });
            db.Statistics.Add(new StatisticsEnt {
                Date = DateTime.Now, AverageCostOfGoods = 50, AverageSellingPrice = 25, NumberOfGoodsSold = 2, QuantityOfGoodsInStock = 5
            });
            db.Products.AddRange(new ProductEnt[]
            {
                new ProductEnt {
                    DateOfPurchase = DateTime.Now, DateOfSale = DateTime.Now, CategoryId = 1, CostPrice = 25, Description = "Красная", InvoiceForPurchaseId = 1, Name = "Тачка"/*, SalesInvoiceId=1*/
                },
                new ProductEnt {
                    DateOfPurchase = DateTime.Now, DateOfSale = DateTime.Now, CategoryId = 2, CostPrice = 25, Description = "Желтый", InvoiceForPurchaseId = 1, Name = "Чай"/*, SalesInvoiceId=1*/
                },
                new ProductEnt {
                    DateOfPurchase = DateTime.Now, DateOfSale = DateTime.Now, CategoryId = 3, CostPrice = 25, Description = "Зеленый", InvoiceForPurchaseId = 1, Name = "Молоток"/*, SalesInvoiceId=1*/
                },
            });
            db.SaveChanges();
        }