public IHttpActionResult AssignPackage([FromUri]int packageId, [FromBody]int employeeId)
 {
     var package = context.Packages.Find(packageId);
     var employee = context.Employees.Find(employeeId);
     package.Status = PackageStatus.InDelivery;
     employee.Packages.Add(package);
     context.PackageEvents.Add(new PackageEvent
     {
         Employee = employee,
         Package = package,
         EventType = PackageEventType.HandedToCourier
     });
     context.SaveChanges();
     using (var eh = new EMailHelper())
     {
         eh.SendEmail(employee.Email, "Instant Delivery - Nowe zlecenie", eh.AssignedPackageBody(employee));
     }
     return Ok();
 }
 /// <summary>
 /// Dodaje pracownika do bazy danych
 /// </summary>
 /// <param name="newEmployee">Nowy pracownik</param>
 public IHttpActionResult Post(EmployeeAddDto newEmployee)
 {
     if (!ModelState.IsValid)
     {
         return BadRequest();
     }
     Employee employee = Mapper.Map<Employee>(newEmployee);
     var password = RandomString(15);
     var role = newEmployee.Role;
     var user = new User { UserName = GenerateUserName(employee) };
     if (context.Users.Any(u => user.UserName == u.UserName))
     {
         return BadRequest();
     }
     var result = userManager.Create(user, password);
     if (!result.Succeeded)
     {
         return BadRequest(result.Errors.ToString());
     }
     userManager.AddToRole(user.Id, role.ToString());
     employee.User = user;
     context.Employees.Add(employee);
     context.SaveChanges();
     using (var eh = new EMailHelper())
     {
         eh.SendEmail(employee.Email, "Instant Delivery - Rejestracja", eh.RegistrationBody(employee, password));
     }
     return Ok(employee.Id);
 }