public void CreateEmployee(EmployeeCreate model)
 {
     var entity = new Employee
     {
         Name = model.Name,
     };
 }
        public async Task <ActionResult> Create([FromBody] EmployeeCreate request)
        {
            if (ModelState.IsValid)
            {
                var employeeDto = request.ToDto();
                await _context.Create(employeeDto);

                return(Ok());
            }

            return(BadRequest("model validation failed"));
        }
        public IHttpActionResult Post(EmployeeCreate employee)
        {
            if (employee == null)
            {
                return(BadRequest("Received model was null."));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Ok("Hello " + employee.Name));
        }
        public async Task <IActionResult> Create([FromBody] EmployeeCreate model)
        {
            try
            {
                var result = await _employeeService.Create(model);

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IActionResult> Create(EmployeeCreate model)
        {
            if (model.MobileNumber.StartsWith('0'))
            {
                model.MobileNumber = "962" + model.MobileNumber.Substring(1);
            }
            else
            {
                model.MobileNumber = "962" + model.MobileNumber;
            }
            CheckCredetials(model.Username, model.Email, model.MobileNumber);
            long userId = _principalService.GetUserId();
            var  result = await CreateUser(userId, model);

            if (result != 0)
            {
                Employee employee = new Employee
                {
                    Address           = model.Address,
                    CreatedAt         = DateTime.Now,
                    CreatedById       = userId,
                    Department        = model.Department,
                    DirectManagerId   = model.DirectManagerId.HasValue ? model.DirectManagerId : null,
                    Email             = model.Email,
                    FamilyMemberCount = model.FamilyMemberCount,
                    FullNameAr        = model.FullNameAr,
                    FullNameEn        = model.FullNameEn,
                    HiringDate        = model.HiringDate,
                    IsActive          = true,
                    EmployeeGuid      = Guid.NewGuid(),
                    JobTitleName      = model.JobTitleName,
                    MartialStatus     = model.MartialStatus,
                    MobileNumber      = model.MobileNumber,
                    Salary            = model.Salary,
                    SSN             = model.SSN,
                    UserId          = result,
                    Username        = model.Username,
                    RemainingSalary = model.Salary
                };
                await _db.Employees.AddAsync(employee);

                int empResult = await _db.SaveChangesAsync();

                if (empResult == 1)
                {
                    return(new OkObjectResult(empResult));
                }
                throw new Exception("حصل خطأ");
            }
            throw new Exception("حصل خطأ");
        }
Beispiel #6
0
        public IHttpActionResult Post(EmployeeCreate employeeById)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateEmployeeService();

            if (!service.CreateEmployee(employeeById))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
        public async Task <bool> CreateAsync(EmployeeCreate newEmp)
        {
            var employee = new Employee
            {
                FullName = newEmp.FullName,
                DOB      = newEmp.DOB,
                Address  = newEmp.Address,
                Gender   = newEmp.Gender
            };
            await _dbcontext.Employees.AddAsync(employee);

            await _dbcontext.SaveChangesAsync();

            return(true);
        }
        public async Task <IActionResult> Create([FromForm] EmployeeCreate request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }

            var result = await _emp.CreateAsync(request);

            if (result)
            {
                return(RedirectToAction("Index"));
            }

            return(View(request));
        }
        public ActionResult Create(EmployeeCreate model)
        {
            var service = CreateEmployeeService();

            //service.CreateEmployee(model);
            if (service.CreateEmployee(model))
            {
                TempData["SaveResult"] = "The Employee was created successfully!";
                return(RedirectToAction(nameof(Index)));
            }
            //if(_db.SaveChanges() == 1)
            //{
            //    return RedirectToAction("Index");
            //}

            return(View(model));
        }
        public bool CreateEmployee(EmployeeCreate model)
        {
            Employee entity = new Employee()
            {
                EmployeeGuid = _userId,
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                HiringDate   = model.HiringDate,
                ShiftId      = model.ShiftId
            };

            using (ApplicationDbContext ctx = new ApplicationDbContext())
            {
                ctx.Employees.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #11
0
        public async Task UpdateAsync(EmployeeCreate entity)
        {
            await DbContextManager.BeginTransactionAsync();

            try
            {
                var spParameters = new SqlParameter[7];
                spParameters[0] = new SqlParameter()
                {
                    ParameterName = "EmpId", Value = entity.EmployeeId
                };
                spParameters[1] = new SqlParameter()
                {
                    ParameterName = "FirstName", Value = entity.FirstName
                };
                spParameters[2] = new SqlParameter()
                {
                    ParameterName = "LastName", Value = entity.LastName
                };
                spParameters[3] = new SqlParameter()
                {
                    ParameterName = "Email", Value = entity.Email
                };
                spParameters[4] = new SqlParameter()
                {
                    ParameterName = "MobileNumber", Value = entity.MobileNumber
                };
                spParameters[5] = new SqlParameter()
                {
                    ParameterName = "Salary", Value = entity.Salary
                };
                spParameters[6] = new SqlParameter()
                {
                    ParameterName = "JoinDate", Value = entity.JoinDate
                };

                await DbContextManager.StoreProc <StoreProcResult>("[dbo].spEmployeeUpdate", spParameters);

                await DbContextManager.CommitAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                DbContextManager.RollbackTransaction();
            }
        }
Beispiel #12
0
        /// <summary>
        /// Use to create an Employee on Scribe with required details
        /// </summary>
        /// <param name="_connectionInfo"></param>
        /// <param name="employee"></param>
        /// <returns></returns>

        public string CreateEmployee(IDictionary <string, string> _connectionInfo, EmployeeCreateFlat employee)
        {
            completeUrl = string.Concat(BaseUrl, CreateEmployeeUri);
            FlatToHierarchical flat            = new FlatToHierarchical();
            EmployeeCreate     employeeRequest = flat.ConvertEmployeeFlatToHierarchical(employee);

            string employeeJsonContent = JsonConvert.SerializeObject(employeeRequest,
                                                                     new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                //DefaultValueHandling = DefaultValueHandling.Ignore
            }
                                                                     );


            HttpWebResponse response = service.HttpRequest(_connectionInfo, completeUrl, HttpMethods.POST.ToString(), employeeJsonContent);

            try
            {
                if (response != null && response.StatusCode == HttpStatusCode.OK)
                {
                    var encoding = ASCIIEncoding.ASCII;
                    using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding))
                    {
                        var resp = reader.ReadToEnd();
                        return("Ok");
                    }
                }
                else if ((response.StatusCode == HttpStatusCode.BadRequest))
                {
                    throw new WebException("Request is malformed. Correct and resubmit.");
                }
                else if ((response.StatusCode == HttpStatusCode.InternalServerError))
                {
                    throw new WebException("An Unexpected Server Error Occued.");
                }
                else
                {
                    throw new WebException("Unable to Create this information for DayForce");
                }
            }
            catch (WebException ex)
            {
                throw new WebException(ex.Message);
            }
        }
        public ActionResult Create(EmployeeCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateEmployeeService();

            if (service.CreateEmployee(model))
            {
                TempData["SaveResult"] = "Your employee was created.";
                return(RedirectToAction("Index"));
            }
            ;

            return(View(model));
        }
Beispiel #14
0
        public ActionResult Create(EmployeeCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateEmployeeService();

            if (service.CreateEmployee(model))
            {
                TempData["SaveResult"] = "Employee has successfully been added";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Employee cannot be added");
            return(View(model));
        }
        public bool CreateEmployee(EmployeeCreate model)
        {
            var entity =
                new Employee()
            {
                Employee_Id = Guid.NewGuid().ToString(),
                FullName    = model.FullName,
                Title       = model.Title,
                PayRate     = model.PayRate,
                HireDate    = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Employees.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(EmployeeCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            Guid            userId  = Guid.Parse(User.Identity.GetUserId());
            EmployeeService service = new EmployeeService(userId);

            if (service.CreateEmployee(model))
            {
                TempData["SaveResult"] = "Employee successfully created.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Employee could not be created");
            return(View());
        }
Beispiel #17
0
        //POST
        public bool NewEmployee(EmployeeCreate model)
        {
            Employee newEmployee = new Employee()
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                MuseumId  = model.MuseumId,
                Position  = model.Position,
                Id        = model.Id,
                OwnerId   = _userId
            };

            using (var db = new ApplicationDbContext())
            {
                db.Employees.Add(newEmployee);
                return(db.SaveChanges() == 1);
            }
        }
        public Employees_tests()
        {
            _employeeController = new EmployeeController(_IEmployeeRepository.Object);

            _employeeDto = new EmployeeDto()
            {
                Name           = "Gvidas",
                Surname        = "Nor",
                Address        = "Sauletekio ave. 18., Vilnius",
                BirthDate      = DateTime.Now,
                Email          = "*****@*****.**",
                Password       = "******",
                PersonalCode   = "3888888878",
                Phone          = "8655547558",
                EmploymentDate = DateTime.Now.ToString(),
                Id             = 2,
            };

            _employeeCreate = new EmployeeCreate()
            {
                Name           = "Gvidas",
                Surname        = "Nor",
                Address        = "Sauletekio ave. 18., Vilnius",
                BirthDate      = DateTime.Now,
                Email          = "*****@*****.**",
                Password       = "******",
                PersonalCode   = "3888888878",
                Phone          = "8655547558",
                EmploymentDate = DateTime.Now.ToString()
            };

            _employeeUpdate = new EmployeeUpdate()
            {
                Name           = "Gvidas",
                Surname        = "Nor",
                Address        = "Sauletekio ave. 18., Vilnius",
                BirthDate      = DateTime.Now,
                Email          = "*****@*****.**",
                Password       = "******",
                PersonalCode   = "3888888878",
                Phone          = "8655547558",
                EmploymentDate = DateTime.Now.ToString()
            };
        }
Beispiel #19
0
        public IHttpActionResult PostCreate(EmployeeCreate employeeCreate)
        {
            var employee = new Employee
            {
                FirstName   = employeeCreate.FirstName,
                LastName    = employeeCreate.LastName,
                Designation = employeeCreate.Designation
            };

            using (ISession session = NHibernateSession.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.SaveOrUpdate(employee);
                    transaction.Commit();
                    return(Ok());
                }
            }
        }
Beispiel #20
0
        public bool CreateEmployee(EmployeeCreate model)
        {
            var entity =
                new Employee()
            {
                OwnerId          = _userId,
                EmployeeId       = model.EmployeeId,
                FirstName        = model.FirstName,
                LastName         = model.LastName,
                JobTitle         = model.JobTitle,
                LevelOfEducation = model.LevelOfEducation,
                CreatedUtc       = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Employees.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #21
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <EMPLOYEE>
            <PERSONALINFO>
                <CONTACTNAME>John Smith</CONTACTNAME>
            </PERSONALINFO>
        </EMPLOYEE>
    </create>
</function>";

            EmployeeCreate record = new EmployeeCreate("unittest")
            {
                ContactName = "John Smith"
            };

            this.CompareXml(expected, record);
        }
        public bool CreateEmployee(EmployeeCreate model)
        {
            var entity =
                new Employee()
            {
                ManagerId      = _userId,
                Name           = model.Name,
                AvailableHours = model.AvailableHours,
                WageAmount     = model.WageAmount,
                Rating         = model.Rating,
                CanOpen        = model.CanOpen,
                CanClose       = model.CanClose
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Employees.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #23
0
        //Create Personnel
        public bool CreateEmployee(EmployeeCreate model)
        {
            var entity =
                new Employee()
            {
                FirstName            = model.FirstName,
                LastName             = model.LastName,
                MiddleName           = model.MiddleName,
                SocialSecurityNumber = model.SocialSecurityNumber,
                DateOfBirth          = model.DateOfBirth,
                DateOfHire           = model.DateOfHire,
                DateOfTermination    = model.DateOfTermination,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.EmployeeDbSet.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #24
0
        public bool CreateEmployee(EmployeeCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var managerName = ctx.Managers.Find(model.ManagerId);
                var entity      =

                    new Employee()
                {
                    EmployeeOwnerId   = _userId,
                    OwnerId           = _userId,
                    EmployeeFirstName = model.EmployeeFirstName,
                    EmployeeLastName  = model.EmployeeLastName,
                    ManagerId         = model.ManagerId,
                    HiredDate         = model.HiredDate,
                    Dept = model.Dept,
                };
                ctx.Employees.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        private async Task <long> CreateUser(long userId, EmployeeCreate model)
        {
            ApplicationUser user = new ApplicationUser
            {
                CreatedAt    = DateTime.Now,
                CreatedBy    = userId,
                Email        = model.Email,
                FullName     = model.FullNameAr,
                IsActive     = true,
                MobileNumber = model.MobileNumber,
                UserName     = model.Username
            };
            IdentityResult result = await _userManager.CreateAsync(user, model.Password);

            CreateRoleIfNotExist(model.Role, user.Id);
            if (result.Succeeded)
            {
                return(user.Id);
            }
            throw new Exception("حصل خطأ");
        }
Beispiel #26
0
        // Create Employee
        public bool CreateEmployee(EmployeeCreate model)
        {
            var employee =
                new Employee()
            {
                OwnerId         = _userId,
                Name            = model.Name,
                Address         = model.Address,
                City            = model.City,
                State           = model.State,
                PhoneNumber     = model.PhoneNumber,
                EmailAddress    = model.EmailAddress,
                EmployeeCreated = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Employees.Add(employee);
                return(ctx.SaveChanges() == 1);
            }
        }
        public bool CreateEmployee(EmployeeCreate model)
        {
            var entity =
                new Employee()
            {
                IndividualId   = _userId,
                FullName       = model.FullName,
                Phone          = model.Phone,
                Email          = model.Email,
                HireDate       = model.HireDate,
                BirthDate      = model.BirthDate,
                Gender         = model.Gender,
                TypeOfPosition = model.TypeOfPosition,
                DeptId         = model.DeptId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Employees.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #28
0
        public bool CreateEmployee(EmployeeCreate model)
        {
            var entity =
                new Employee()
            {
                UserID        = _userID,
                FirstName     = model.FirstName,
                LastName      = model.LastName,
                EmployeeID    = model.EmployeeID,
                JobTitle      = model.JobTitle,
                StreetAddress = model.StreetAddress,
                City          = model.City,
                State         = model.State,
                ZipCode       = model.ZipCode,
                PhoneNumber   = model.PhoneNumber,
                Email         = model.Email,
                HireDate      = model.HireDate,
            };

            _context.Employees.Add(entity);
            return(_context.SaveChanges() == 1);
        }
Beispiel #29
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <EMPLOYEE>
            <PERSONALINFO>
                <CONTACTNAME>John Smith</CONTACTNAME>
            </PERSONALINFO>
        </EMPLOYEE>
    </create>
</function>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            EmployeeCreate record = new EmployeeCreate("unittest");

            record.ContactName = "John Smith";

            record.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
Beispiel #30
0
 public IHttpActionResult Create(EmployeeCreate employee)
 {
     _employeeService.Create(employee);
     return(Ok());
 }