Example #1
0
        private AssignedSalesPerson ParseToAssignedSalesPerson(SalesPersonAndGroup chosenperson)
        {
            AssignedSalesPerson assignedSalesPerson = new AssignedSalesPerson();

            assignedSalesPerson.SalesPersonName = chosenperson.Name;
            foreach (var g in chosenperson.Groups)
            {
                var f = SalesPersonSpeciality.Groups.FirstOrDefault(x => x.GroupName == g);
                if (f != null)
                {
                    assignedSalesPerson.SpecialityList.Add(f.GroupDescription);                    //
                }
            }

            return(assignedSalesPerson);
        }
        public AssignedSalesPerson Post([FromBody] SalesPersonRequest salesPersonRequest)
        {
            try
            {
                AssignedSalesPerson assignedSalesPerson = salesPersonAssignmentService
                                                          .AssignTheMostSuitableSalesPerson(salesPersonRequest);

                return(assignedSalesPerson);
            }
            catch (Exception ex)
            {
                Response.StatusCode = 500;
                HttpContext.Response.HttpContext.Features.Get <IHttpResponseFeature>().ReasonPhrase = ex.Message;
                return(null);
            }
        }