public async Task <ConsultantResource> GetByID(int id)
        {
            var consultant = await _consultantService.GetById(id);

            var resource = _mapper.Map <Consultant, ConsultantResource>(consultant);

            return(resource);
        }
        public JsonResult CalendarData(Guid?consultantId)
        {
            var calendarEntries = new List <object>();

            if (consultantId.HasValue)
            {
                var employee = _consultantService.GetById(consultantId.Value);

                foreach (var timeAllocation in employee.TimeAllocations)
                {
                    string title       = "";
                    string address     = "";
                    var    appointment = timeAllocation as AppointmentDto;
                    if (appointment != null)
                    {
                        title = appointment.LeadName;
                    }
                    if (appointment != null)
                    {
                        address = appointment.Address;
                    }

                    calendarEntries.Add(new
                    {
                        id = timeAllocation.Id,
                        consultantId,
                        isAppointment = (appointment != null),
                        title,
                        start    = DateHelper.ToUnixTimespan(timeAllocation.Start),
                        end      = DateHelper.ToUnixTimespan(timeAllocation.End),
                        isoStart = timeAllocation.Start.ToString("yyyy-MM-dd HH:mm:ss"),
                        isoEnd   = timeAllocation.End.ToString("yyyy-MM-dd HH:mm:ss"),
                        address,
                        backgroundColor = (appointment != null) ? "indianred" : "lightgrey",
                        borderColor     = (appointment != null) ? "indianred" : "lightgrey",
                    });
                }
            }

            return(Json(calendarEntries, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public IActionResult GetById(Guid id)
        {
            var c = accountConsultantService.GetById(id);

            if (c == null)
            {
                return(NotFound());
            }

            var accountConsultantDto = Mapper.MapAccountConsultant(c);

            var accountFromDb    = accountService.GetById(c.AccountId);
            var consultantFromDb = consultantService.GetById(c.ConsultantId);
            var employeeFromDb   = employeeService.GetById(c.EmployeeId);

            accountConsultantDto.Account    = Mapper.MapAccount(accountFromDb);
            accountConsultantDto.Consultant = Mapper.MapConsultant(consultantFromDb);
            accountConsultantDto.Employee   = Mapper.MapEmployee(employeeFromDb);

            return(Ok(accountConsultantDto));
        }
Example #4
0
        public IActionResult GetById(Guid id)
        {
            var c = consultantService.GetById(id);

            if (c == null)
            {
                return(NotFound());
            }

            var consultantDto = new ConsultantDto
            {
                FirstName = c.Firstname,
                LastName  = c.Lastname,
                Email     = c.Email,
                WorkEmail = c.WorkEmail,
                Telephone = c.Telephone,
                Mobile    = c.Mobile,
                Straat    = c.Address?.Straat,
                Number    = c.Address?.Number,
                Country   = c.Address?.Country,
                Zipcode   = c.Address?.Zipcode
            };

            var contractsFromDb = contractService.GetContractsForConsultant(id);

            consultantDto.Contracts = new List <ContractDto>();
            foreach (Contract con in contractsFromDb)
            {
                consultantDto.Contracts.Add(new ContractDto
                {
                    EndDate     = con.EndDate,
                    StartDate   = con.StartDate,
                    DocumentUrl = con.DocumentUrl,
                    Salary      = con.Salary,
                    SignedDate  = con.SignedDate
                });
            }

            return(Ok(consultantDto));
        }
Example #5
0
        public IActionResult Get(Guid id)
        {
            entitiesContext.Consultants.Include(Consultant => Consultant.Address).ToList();
            entitiesContext.Consultants.Include(Consultant => Consultant.Employee).ToList();
            entitiesContext.Consultants.Include(Consultant => Consultant.Account).ToList();
            entitiesContext.Contracts.Include(contracts => contracts.ContractType).ToList();

            var c = service.GetById(id);

            if (c == null)
            {
                return(NotFound());
            }
            var consultant = new ConslutantDto()
            {
                Firstname = c.Firstname,
                Lastname  = c.Lastname,
                Email     = c.Email,
                WorkEmail = c.WorkEmail,
                Telephone = c.Telephone,
                Mobile    = c.Mobile,
                Birthdate = c.Birthdate,
                AddressId = c.Address.Id,
                Street    = c.Address?.Street,
                Number    = c.Address?.Number,
                Country   = c.Address?.Country,
                City      = c.Address?.City,
                Zip       = c.Address.Zip,

                EmployeeId = c.Employee == null ? Guid.Empty : c.Employee.Id,

                AccountId = c.Account == null ? Guid.Empty : c.Account.Id
            };

            var contractFromDB = this.contractService.GetContractForConsultants(id);

            consultant.Contracts = new List <ContractDto>();
            foreach (Contract cont in contractFromDB)
            {
                var procent = ((cont.PurchasePrice * 100) / cont.SellingPrice);
                consultant.Contracts.Add(new ContractDto
                {
                    EndDate           = cont.EndDate,
                    StartDate         = cont.StartDate,
                    Date              = cont.StartDate.ToString("yyyy/MM"),
                    DocumentUrl       = cont.DocumentUrl,
                    Salary            = cont.Salary,
                    SignedDate        = cont.SignedDate,
                    Commentary        = cont.Commentary,
                    PurchasePrice     = cont.PurchasePrice,
                    SellingPrice      = cont.SellingPrice,
                    Margin            = (cont.SellingPrice - cont.PurchasePrice),
                    MarginPercent     = 100 - procent,
                    Id                = cont.Id,
                    ConsultantId      = cont.ConsultantId,
                    ContractTypeId    = cont.ContractTypeId,
                    ContractTypeTitle = cont.ContractType.Title,
                });;
            }
            return(Ok(consultant));
        }