Beispiel #1
0
        public EmployeeByBusinessPartnerResponse Delete(EmployeeByBusinessPartnerViewModel employeeByBysinessPartner)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            try
            {
                EmployeeByBusinessPartner deletedEmployeeByBusinessPartner = unitOfWork.GetEmployeeByBusinessPartnerRepository()
                                                                             .Delete(employeeByBysinessPartner.ConvertToEmployeeByBusinessPartner());

                Employee        employee        = unitOfWork.GetEmployeeRepository().GetEmployee((int)deletedEmployeeByBusinessPartner.EmployeeId);
                BusinessPartner businessPartner = unitOfWork.GetBusinessPartnerRepository().GetBusinessPartner((int)deletedEmployeeByBusinessPartner.BusinessPartnerId);

                EmployeeCard ec = new EmployeeCard()
                {
                    Identifier  = Guid.NewGuid(),
                    EmployeeId  = deletedEmployeeByBusinessPartner.EmployeeId,
                    CardDate    = (DateTime)deletedEmployeeByBusinessPartner.RealEndDate,
                    Description = "Radnik " + employee?.Name + " " + employee?.SurName + " je raskinuo ugovor sa firmom " + businessPartner?.Name + ". Prestanak je od: " + ((DateTime)deletedEmployeeByBusinessPartner.RealEndDate).ToString("dd.MM.yyyy"),
                    PlusMinus   = "-",
                    CreatedById = deletedEmployeeByBusinessPartner.CreatedById,
                    CompanyId   = deletedEmployeeByBusinessPartner.CompanyId,
                    CreatedAt   = DateTime.Now,
                    UpdatedAt   = DateTime.Now
                };
                unitOfWork.GetEmployeeCardRepository().Create(ec);

                unitOfWork.Save();

                response.EmployeeByBusinessPartner = deletedEmployeeByBusinessPartner.ConvertToEmployeeByBusinessPartnerViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.EmployeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Beispiel #2
0
        public EmployeeByBusinessPartnerResponse Create(EmployeeByBusinessPartnerViewModel re)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            try
            {
                EmployeeByBusinessPartner addedEmployeeByBusinessPartner = unitOfWork.GetEmployeeByBusinessPartnerRepository()
                                                                           .Create(re.ConvertToEmployeeByBusinessPartner());

                EmployeeCard ec = new EmployeeCard()
                {
                    Identifier  = Guid.NewGuid(),
                    EmployeeId  = re.Employee.Id,
                    CardDate    = re.StartDate,
                    Description = "Radnik " + re.Employee?.Name + " " + re.Employee?.SurName + " je sklopio ugovor sa firmom " + re.BusinessPartner?.Name + ". Radnik je u firmi 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.EmployeeByBusinessPartner = addedEmployeeByBusinessPartner.ConvertToEmployeeByBusinessPartnerViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.EmployeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }