Пример #1
0
        public JsonResult InsertOrUpdate(EmployeeVm employeeVm)
        {
            try
            {
                var json        = JsonConvert.SerializeObject(employeeVm);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(json);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                if (employeeVm.EmployeeId == null || employeeVm.EmployeeId.Equals(""))
                {
                    var result = client.PostAsync("employees", byteContent).Result;
                    return(Json(result));
                }
                else if (employeeVm.EmployeeId != null)
                {
                    var result = client.PutAsync("employees/" + employeeVm.EmployeeId, byteContent).Result;
                    return(Json(result));
                }

                return(Json(404));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public ActionResult EditInfo(EmployeeVm model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (Db db = new Db())
            {
                var tbl = db.EmployeeTbls.Find(model.EmployeeId);
                if (tbl != null)
                {
                    tbl.EmployeeName     = model.EmployeeName;
                    tbl.PresentAddress   = model.PresentAddress;
                    tbl.PermanentAddress = model.PermanentAddress;
                    tbl.LocationId       = model.LocationId;
                    tbl.PositionId       = model.PositionId;
                    tbl.Gender           = model.Gender;
                    tbl.Phone            = model.PhoneNumber;
                    tbl.IsUserOfSystem   = model.IsUserOfSystem;
                    tbl.DateOfBirth      = model.DateOfBirth;
                    tbl.JoiningDate      = model.JoiningDate;
                    tbl.Salary           = model.Salary;

                    db.SaveChanges();
                }
            }

            TempData["SM"] = "You Have Updated A Employee Information";

            return(this.RedirectToAction("EditInfo"));
        }
Пример #3
0
        public ActionResult Update(int id, [FromBody] EmployeeVm employeeVm)
        {
            try
            {
                var updatingEmployee = _context.Employee.Find(id);
                if (updatingEmployee == null)
                {
                    return(BadRequest("Employee not found"));
                }

                updatingEmployee.Name      = employeeVm.Name;
                updatingEmployee.BirthDate = employeeVm.BirthDate;
                updatingEmployee.StartDate = employeeVm.StartDate;
                updatingEmployee.Gender    = employeeVm.Gender;
                updatingEmployee.Email     = employeeVm.Email;
                updatingEmployee.CPF       = employeeVm.CPF;
                updatingEmployee.Team      = employeeVm.Team;

                _context.SaveChanges();
                return(Ok(updatingEmployee));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #4
0
        public EmployeeVm Init(long userId, long?id)
        {
            var user = BlUser.LoadSingle(userId);

            var toRet = new EmployeeVm
            {
                Branches   = BlBranch.GetLov(userId, true).ToDictionary(i => i.value, i => i.label),
                Titles     = BlCode.LoadTable(userId, "Title"),
                Genders    = BlCode.LoadTable(userId, "Gender"),
                IdTypes    = BlCode.LoadTable(userId, "IdType"),
                Maritals   = BlCode.LoadTable(userId, "Marital"),
                Statuses   = BlCode.LoadTable(userId, "Status"),
                Levels     = BlCode.LoadTable(userId, "EmployeeLevel"),
                ActionMode = Enumerations.ActionMode.Add,
                Employee   = new Employee {
                    Status = "A", Entity = new Entity {
                        BranchId = user.BranchId, Nationality = 422, Status = "A"
                    }, Level = "0"
                }
            };

            if (id != null)
            {
                var obj = LoadSingle(userId, Convert.ToInt64(id));
                toRet.Employee   = obj;
                toRet.ActionMode = Enumerations.ActionMode.Edit;
                toRet.Signature  = BlCommon.GetSignature(toRet.Employee.UserId, toRet.Employee.EntryDate);
            }

            return(toRet);
        }
Пример #5
0
        public void Controller_Add()
        {
            var employee = new EmployeeVm
            {
                Name            = "Igor",
                CompanyId       = 2,
                ExperienceLevel = "C",
                Salary          = 1000,
                StartingDate    = new DateTime(2018, 11, 11),
                VacationDays    = 21
            };

            var mockMapper = new Mock <IMapper <EmployeeVm> >();

            mockMapper.Setup(m => m.Insert(employee)).Callback((EmployeeVm e) =>
            {
                e.Id = new Random().Next();
            });

            var controller = new EmployeeController(mockMapper.Object);

            var result = controller.Post(employee);

            Assert.IsType <EmployeeVm>(result);
            Assert.True(employee.Id > 0);
            Assert.Equal(employee.Name, result.Name);
        }
Пример #6
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                Employee = this.serviceFactory.EmployeeService.Update(Employee);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(Employee.EmployeeId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public IActionResult Edit(EmployeeVm employee)
        {
            logger.LogDebug($"Employee.Edit [post] is called");
            try
            {
                if (employee == null)
                {
                    throw new ArgumentException("Variable shuld not be null", nameof(employee));
                }
                if (ModelState.IsValid)
                {
                    EmployeeService.Update(ConvertToEmployeeDto.Convert(employee));
                }
                else
                {
                    return(View(employee));
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(View("Error"));
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #8
0
 /// <summary>
 /// This method will delete employee details
 /// </summary>
 /// <param name="objEmp">Object holdling EmployeeId</param>
 /// <returns>Returns ResultStatus enum which reflect the status of operation performed</returns>
 public ResultStatus DeleteRecord(EmployeeVm objEmp)
 {
     try
     {
         using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities())
         {
             try
             {
                 var employee = DbContext.Employees.FirstOrDefault(x => x.EmployeeId == objEmp.EmployeeId);
                 if (employee != null)
                 {
                     DbContext.Employees.Remove(employee);
                     DbContext.SaveChanges();
                 }
                 else
                 {
                     return(ResultStatus.QueryNotExecuted);
                 }
             }
             catch (Exception)
             {
                 return(ResultStatus.QueryNotExecuted);
             }
         }
     }
     catch (Exception)
     {
         return(ResultStatus.ConnectionError);
     }
     return(ResultStatus.Success);
 }
Пример #9
0
        public ActionResult Index(EmployeeVm model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (Db db = new Db())
            {
                EmployeeTbl tbl = new EmployeeTbl();
                tbl.EmployeeName     = model.EmployeeName;
                tbl.PresentAddress   = model.PresentAddress;
                tbl.PermanentAddress = model.PermanentAddress;
                tbl.LocationId       = model.LocationId;
                tbl.PositionId       = model.PositionId;
                tbl.Gender           = model.Gender;
                tbl.Phone            = model.PhoneNumber;
                tbl.IsUserOfSystem   = model.IsUserOfSystem;
                tbl.DateOfBirth      = model.DateOfBirth;
                tbl.JoiningDate      = model.JoiningDate;
                tbl.Salary           = model.Salary;
                //tbl.MaritalStatus = model.MaritalStatus;
                int id = model.EmployeeId;

                db.EmployeeTbls.Add(tbl);
                db.SaveChanges();
            }

            TempData["SM"] = "You Have Added A Employee Information";

            return(RedirectToAction("Index"));
        }
Пример #10
0
        public void AlterEmployee()
        {
            int      id       = EmployeeView.RequestId();
            Employee employee = _repository.GetById(id);

            if (employee != null)
            {
                EmployeeVm employeeVm = new EmployeeVm()
                {
                    Name = employee.Name, Country = employee.Country, HourlyRate = employee.HourlyRate.ToString(), HoursWorked = employee.HoursWorked.ToString()
                };

                if (EmployeeView.ShowAlterEmployeeView(employeeVm))
                {
                    employee.Name        = employeeVm.Name;
                    employee.Country     = employeeVm.Country;
                    employee.HourlyRate  = double.Parse(employeeVm.HourlyRate);
                    employee.HoursWorked = int.Parse(employeeVm.HoursWorked);

                    try
                    {
                        _repository.Add(employee);
                        EmployeeView.ShowMessage("Funcionário alterado com sucesso.");
                    }
                    catch (Exception e)
                    {
                        EmployeeView.ShowMessage("Erro ao alterar o Funcionário.");
                    }
                }
            }
            else
            {
                EmployeeView.ShowMessage("Funcionário não encontrado.");
            }
        }
        public IActionResult Edit(int id)
        {
            logger.LogDebug($"Employee.Edit [get] is called");
            EmployeeDto EmployeeDto = EmployeeService.Get(id);
            EmployeeVm  model       = ConvertToEmployeeVm.Convert(EmployeeDto);

            return(View("CreateOrEdit", model));
        }
Пример #12
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Employee = this.serviceFactory.EmployeeService.Create(Employee);

            return(RedirectToPage("./Index"));
        }
 public int PracticePost(EmployeeVm employeeVm)
 {
     try
     {
         var result = _unitOfWork.Practice.PostPracticeMaster(employeeVm);
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #14
0
        public async Task <IActionResult> Add(int companyId)
        {
            var availableLevelsVm = await this.GetAvailableLevels();

            var employeeVm = new EmployeeVm
            {
                CompanyId       = companyId,
                AvailableLevels = availableLevelsVm,
                StartingDate    = DateTime.UtcNow,
            };

            return(this.View(employeeVm));
        }
Пример #15
0
        public static bool ShowAlterEmployeeView(EmployeeVm employee)
        {
            RequestAlteration(employee, "Nome: ", employee.Name, "Name", Employee.ValidateName);
            RequestAlteration(employee, "Valor por hora: R$", employee.HourlyRate, "HourlyRate", Employee.ValidateHourlyRate);
            RequestAlteration(employee, "Horas trabalhadas: ", employee.HoursWorked, "HoursWorked", Employee.ValidateHoursWorked);
            RequestAlteration(employee, "País: ", employee.Country, "Country", Employee.ValidateCountry);

            var confirmation = new ConsoleConfirmation("\nRevise as informações abaixo sobre o funcionário.\n\n" + employee + "\nConfirmar?");

            confirmation.Show();

            return(confirmation.Confirmed);
        }
Пример #16
0
        private static void RequestAlteration(EmployeeVm emp, string text, string value, string property, InputText.InputValidator validator)
        {
            var conMessage = new ConsoleMessage(text + value);

            conMessage.Show();

            var confirmation = new ConsoleConfirmation("Alterar?");

            confirmation.Show();
            if (confirmation.Confirmed)
            {
                new BindInputText <EmployeeVm>(text, emp, property, validator).Show();
            }
        }
Пример #17
0
        public static EmployeeVm GetEmployeeVm(int empId = 0)
        {
            EmployeeVm empVm = new EmployeeVm();

            if (empId != 0)
            {
                HREntities db    = new HREntities();
                Employee   empDb = db.Employees.Where(x => x.EmpId == empId).FirstOrDefault();
                Mapper.CreateMap <Employee, EmployeeVm>().IgnoreAllNonExisting();
                Mapper.Map(empDb, empVm);
            }

            return(empVm);
        }
Пример #18
0
        public IHttpActionResult SaveEmployee([FromBody] EmployeeVm oItem)
        {
            Connect();
            try
            {
                int oGRNLineCount = oItem.Lines.Count;

                Documents documents = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oEmployeesInfo);
                documents.CardCode                = oItem.user_id;
                documents.HandWritten             = SAPbobsCOM.BoYesNoEnum.tNO;
                documents.DocDate                 = (DateTime)oItem.DateCreated;
                documents.DocDueDate              = (DateTime)oItem.DateCreated;
                documents.BPL_IDAssignedToInvoice = 3;

                if (oGRNLineCount > 0)
                {
                    foreach (OrderLineVm row1 in oItem.Lines)
                    {
                        documents.Lines.ItemCode        = row1.SapCode;
                        documents.Lines.ItemDescription = row1.ProductName;
                        documents.Lines.Price           = row1.Price;
                        documents.Lines.Quantity        = row1.Quantity;
                        documents.Lines.LineTotal       = row1.Amount;
                        documents.Lines.Add();
                    }
                }
                int resp = documents.Add();

                if (resp != 0)
                {
                    return(Json(new Error()
                    {
                        ErrorCode = oCompany.GetLastErrorCode().ToString(), Description = oCompany.GetLastErrorDescription()
                    }));
                    //return StatusCode(System.Net.HttpStatusCode.NotFound);
                }
                return(StatusCode(System.Net.HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                oCompany.Disconnect();
                //return Json(new Error() { ErrorCode = ex.Source, Description = ex.Message });
                return(Json(new Error()
                {
                    ErrorCode = oCompany.GetLastErrorCode().ToString(), Description = oCompany.GetLastErrorDescription()
                }));
                //return StatusCode(System.Net.HttpStatusCode.NotFound);
            }
        }
Пример #19
0
        public IActionResult OnGet(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Employee = this.serviceFactory.EmployeeService.GetById(id);

            if (Employee == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #20
0
        public ActionResult Create(EmployeeVm employeeVm)
        {
            try
            {
                var employee = employeeVm.ToModel();
                _context.Employee.Add(employee);
                _context.SaveChanges();

                return(Ok(employee));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #21
0
        private void _UpdateEmployeeOffices(EmployeeVm providerInfo, Employee employee, bool newEmployee)
        {
            var authenticatedOffices = this._ExtractAuthenticatedOffices(providerInfo.Offices);
            var removeOffices        = this._ExtractUnauthenticatedOffices(providerInfo.Offices);

            this.employeeIt2Manager.SaveOrUpdateEmployeeOffices(
                employee.EmployeeId,
                authenticatedOffices,
                authenticatedOffices.Select(o => providerInfo.EyefinityEhr ? 1 : 0).ToList(),
                newEmployee);

            this.employeeIt2Manager.RemoveEmployeeOffices(
                employee.EmployeeId,
                removeOffices);
        }
        public static int CreateEmployee(int employeeId, string firstName, string lastName, string email, string password)
        {
            EmployeeVm data = new EmployeeVm
            {
                EmployeeID = employeeId,
                Firstname  = firstName,
                Lastname   = lastName,
                Email      = email,
                Password   = password
            };

            string sql = @"insert into dbo.Employee(EmployeeId,FirstName,LastName,Email, Password)
                        values(@EmployeeID, @FirstName, @LastName, @Email, @Password);";

            return(SqlDataAccess.SaveData(sql, data));
        }
        public EmployeeVm GetID(string id)
        {
            var        getData = _context.Employees.Include("User").SingleOrDefault(x => x.EmployeeId == id);
            EmployeeVm emp     = new EmployeeVm()
            {
                EmployeeId = getData.EmployeeId,
                Name       = getData.Name,
                Address    = getData.Address,
                Phone      = getData.User.PhoneNumber,
                CreateDate = getData.CreateDate,
                UpdateDate = getData.UpdateDate,
                DeleteData = getData.DeleteData
            };

            return(emp);
        }
Пример #24
0
        private string UploadedFile(EmployeeVm model)
        {
            string uniqueFileName = null;

            if (model.ProfileImage != null)
            {
                string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "images");
                uniqueFileName = Guid.NewGuid().ToString() + "_" + model.ProfileImage.FileName;
                string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    model.ProfileImage.CopyTo(fileStream);
                }
            }
            return(uniqueFileName);
        }
Пример #25
0
        public IActionResult OnPost(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Employee = this.serviceFactory.EmployeeService.GetById(id);

            if (Employee != null)
            {
                Employee = this.serviceFactory.EmployeeService.Delete(Employee.EmployeeId);
            }

            return(RedirectToPage("./Index"));
        }
Пример #26
0
        /// <summary>
        /// This method will add new employee to database
        /// </summary>
        /// <param name="objEmp">Object holding all the details of new employee</param>
        /// <returns>Returns ResultStatus enum which reflect the status of operation performed</returns>
        public ResultStatus SaveAddRecord(EmployeeVm objEmp)
        {
            try
            {
                using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities())
                {
                    try
                    {
                        Data.Model.Employee employee = new Data.Model.Employee();

                        if (objEmp != null)
                        {
                            employee.FirstName   = objEmp.FirstName;
                            employee.LastName    = objEmp.LastName;
                            employee.Email       = objEmp.Email;
                            employee.RoleId      = objEmp.RoleId;
                            employee.LocationId  = objEmp.LocationId;
                            employee.JoiningDate = objEmp.JoiningDate;
                            employee.ReleaseDate = objEmp.ReleaseDate;
                            employee.IsReleased  = objEmp.IsReleased;
                            BusinessLayer.LoginBusinessLayer objLogin = new LoginBusinessLayer();
                            employee.Password = objLogin.EncodePassword("mindfire");

                            DbContext.Employees.Add(employee);
                            int result = DbContext.SaveChanges();
                            if (result < 1)
                            {
                                return(ResultStatus.QueryNotExecuted);
                            }
                        }
                        else
                        {
                            return(ResultStatus.QueryNotExecuted);
                        }
                    }
                    catch (Exception)
                    {
                        return(ResultStatus.QueryNotExecuted);
                    }
                }
            }
            catch (Exception)
            {
                return(ResultStatus.ConnectionError);
            }
            return(ResultStatus.Success);
        }
Пример #27
0
        public EmployeeVm GetEmployee(string officeNumber, int employeeId)
        {
            var result            = new EmployeeVm();
            var mngr              = new EmployeeIt2Manager();
            var employeeIt2       = mngr.GetEmployeeFromIt2(employeeId);
            var ehrSystem         = mngr.GetEmrSystemFromOfficeEmployee(officeNumber, employeeId);
            var allCompanyOffices = this.employeeIt2Manager.GetCompanyOffices(employeeIt2.CompanyId);

            result.Active                 = employeeIt2.Active;
            result.CompanyId              = employeeIt2.CompanyId;
            result.DeaNumber              = employeeIt2.DeaNumber;
            result.EinNumber              = employeeIt2.EinNumber;
            result.EmcSubmitterId         = employeeIt2.EmcSubmitterId;
            result.EmployeeId             = employeeId;
            result.EmployeeNum            = employeeIt2.EmployeeNum;
            result.EmployeeType           = (EmployeeType)Enum.ToObject(typeof(EmployeeType), employeeIt2.EmployeeType);
            result.EmrId                  = employeeIt2.EmrId;
            result.Fax                    = employeeIt2.Fax;
            result.FirstName              = employeeIt2.FirstName;
            result.HipaaDate              = FormatDate(employeeIt2.HipaaDate);
            result.Hl7ProviderId          = employeeIt2.Hl7ProviderId;
            result.LastName               = employeeIt2.LastName;
            result.LicenceNumber          = employeeIt2.LicenceNumber;
            result.NationalProviderId     = employeeIt2.NationalProviderId;
            result.Phone                  = employeeIt2.Phone;
            result.ProfessionalCredential = employeeIt2.ProfessionalCredential;
            result.ProfessionalSignature  = employeeIt2.ProfessionalSignature;
            result.SsnNumber              = employeeIt2.SsnNumber;
            result.TpaNumber              = employeeIt2.TpaNumber;
            result.UserId                 = employeeIt2.UserId;
            result.UserName               = employeeIt2.User.Name.ToLower().Replace(GetUserNamePlaceHolderValue(employeeIt2.CompanyId), string.Empty);
            result.DefaultExamMinutes     = Convert.ToString(employeeIt2.DefaultExamMinutes) + " Min.";
            result.AllowOverbooks         = Convert.ToString(employeeIt2.AllowOverbooks);
            result.EyefinityEhr           = ehrSystem == 1;
            result.IsWebSchedulable       = employeeIt2.IsWebSchedulable;
            result.HomeOffice             = employeeIt2.HomeOffice;
            result.IsElectronicNotifiable = employeeIt2.IsElectronicNotifiable;
            result.Offices                = allCompanyOffices.Select(o => new EmployeeOfficeVm
            {
                EmployeeId            = employeeId,
                OfficeNum             = o.ID,
                OfficeName            = o.Name,
                IsAuthorizedForAccess = employeeIt2.Offices.Any(a => a.OfficeNum == o.ID)
            }).ToList();

            return(result);
        }
Пример #28
0
        public async Task <IActionResult> Edit(EmployeeVm model)
        {
            if (!this.ModelState.IsValid)
            {
                model.AvailableLevels = await this.GetAvailableLevels();

                return(this.View(model));
            }

            var employee = this.mapper.Map <Employee>(model);

            await this.employeeService.Edit(employee);

            this.TempData["SuccessMsg"] = string.Format(SuccessMessage.Edit, "Employee");

            return(this.RedirectToAction("Details", "Employees", new { employeeId = model.Id }));
        }
Пример #29
0
        public HttpResponseMessage AddStaffInformation(string officeNumber, [FromBody] EmployeeVm staffInfo)
        {
            var companyId          = this.employeeIt2Manager.GetCompanyId(officeNumber);
            var userName           = string.Concat(staffInfo.UserName, GetUserNamePlaceHolderValue(companyId));
            var doesStaffIdExist   = CheckForExistingStaffId(staffInfo.EmployeeNum, companyId);
            var doesLoginNameExist = CheckForExistingLoginName(userName, companyId);
            var validationString   = string.Empty;

            if (doesStaffIdExist && doesLoginNameExist)
            {
                validationString = "The Staff ID already exists in the system. Enter a unique Staff ID.<br/>"
                                   + "The Login Name already exists in the system. Enter a unique Login Name.";
            }
            else if (doesStaffIdExist)
            {
                validationString = "The Staff ID already exists in the system. Enter a unique Staff ID.";
            }
            else if (doesLoginNameExist)
            {
                validationString = "The Login Name already exists in the system. Enter a unique Login Name.";
            }
            else
            {
                staffInfo.ProfessionalCredential = string.Empty;
                staffInfo.EmployeeType           = EmployeeType.Staff;
                var employee = staffInfo.ToEmployee();
                employee.User.Name = userName;

                this.employeeIt2Manager.AddStaff(officeNumber, employee);
                this._UpdateEmployeeOffices(staffInfo, employee, true);
                return(this.Request.CreateResponse(
                           HttpStatusCode.OK,
                           new
                {
                    validationmessage = "Staff Added Successfully.",
                    employeeId = employee.EmployeeId,
                    userId = employee.UserId,
                    employeeType = Convert.ToInt32(staffInfo.EmployeeType),
                    isNew = true
                }));
            }

            Logger.Error("AddStaffInformation: " + validationString);
            return(this.Request.CreateResponse(HttpStatusCode.BadRequest, new { validationmessage = validationString }));
        }
Пример #30
0
        public async Task <int> CreateEmployee(EmployeeVm employeeVm)
        {
            var uniqueFileName = UploadedFile(employeeVm);

            employeeVm.ProfilePicture = uniqueFileName;

            var entityEmployee = mapper.Map <Employee>(employeeVm);

            //entityEmployee.ProfilePicture = uniqueFileName;

            employeeRepository.Add(entityEmployee);
            if (await employeeRepository.SaveAll())
            {
                return(entityEmployee.Id);
            }

            return(-1);
        }