public EmployeeByConstructionSiteResponse Create(EmployeeByConstructionSiteViewModel re)
        {
            EmployeeByConstructionSiteResponse response = new EmployeeByConstructionSiteResponse();

            try
            {
                ConstructionSite constructionSite = unitOfWork.GetConstructionSiteRepository().GetConstructionSite(re.ConstructionSite.Id);

                Employee employee = unitOfWork.GetEmployeeRepository().GetEmployeeEntity(re.Employee.Id);
                employee.ConstructionSiteCode = constructionSite.InternalCode;
                employee.ConstructionSiteName = constructionSite.Name;
                employee.UpdatedAt            = DateTime.Now;

                EmployeeByConstructionSite addedEmployeeByConstructionSite = unitOfWork.GetEmployeeByConstructionSiteRepository().Create(re.ConvertToEmployeeByConstructionSite());

                EmployeeCard ec = new EmployeeCard()
                {
                    Identifier  = Guid.NewGuid(),
                    EmployeeId  = re.Employee.Id,
                    CardDate    = addedEmployeeByConstructionSite.StartDate,
                    Description = "Radnik " + employee?.Name + " " + employee?.SurName + " je krenuo da radi na gradilištu " + constructionSite?.Name + ". Radnik je na gradilištu od: " + re.StartDate.ToString("dd.MM.yyyy") + " do " + re.EndDate.ToString("dd.MM.yyyy"),
                    PlusMinus   = "+",
                    CreatedById = re.CreatedBy?.Id,
                    CompanyId   = re.Company?.Id,
                    CreatedAt   = DateTime.Now,
                    UpdatedAt   = DateTime.Now
                };
                unitOfWork.GetEmployeeCardRepository().Create(ec);

                unitOfWork.Save();

                response.EmployeeByConstructionSite = addedEmployeeByConstructionSite.ConvertToEmployeeByConstructionSiteViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.EmployeeByConstructionSite = new EmployeeByConstructionSiteViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
        public EmployeeByConstructionSiteResponse Delete(EmployeeByConstructionSiteViewModel re)
        {
            EmployeeByConstructionSiteResponse response = new EmployeeByConstructionSiteResponse();

            try
            {
                EmployeeByConstructionSite deletedEmployeeByConstructionSite = unitOfWork.GetEmployeeByConstructionSiteRepository().Delete(re.ConvertToEmployeeByConstructionSite());

                Employee         employee         = unitOfWork.GetEmployeeRepository().GetEmployeeEntity((int)deletedEmployeeByConstructionSite.EmployeeId);
                ConstructionSite constructionSite = unitOfWork.GetConstructionSiteRepository().GetConstructionSite((int)deletedEmployeeByConstructionSite.ConstructionSiteId);
                employee.ConstructionSiteCode = "";
                employee.ConstructionSiteName = "";
                employee.UpdatedAt            = DateTime.Now;

                EmployeeCard ec = new EmployeeCard()
                {
                    Identifier  = Guid.NewGuid(),
                    EmployeeId  = deletedEmployeeByConstructionSite.Employee.Id,
                    CardDate    = (DateTime)deletedEmployeeByConstructionSite.RealEndDate,
                    Description = "Radnik " + employee?.Name + " " + employee.SurName + " je prestao da radi na gradilištu " + constructionSite?.Name + ". Prestanak je od: " + ((DateTime)deletedEmployeeByConstructionSite.RealEndDate).ToString("dd.MM.yyyy"),
                    CreatedById = deletedEmployeeByConstructionSite.CreatedById,
                    PlusMinus   = "-",
                    CompanyId   = deletedEmployeeByConstructionSite.CompanyId,
                    CreatedAt   = DateTime.Now,
                    UpdatedAt   = DateTime.Now
                };
                unitOfWork.GetEmployeeCardRepository().Create(ec);

                unitOfWork.Save();

                response.EmployeeByConstructionSite = deletedEmployeeByConstructionSite.ConvertToEmployeeByConstructionSiteViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.EmployeeByConstructionSite = new EmployeeByConstructionSiteViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }