Пример #1
0
        public IActionResult GetById(int id)
        {
            MultiAssistDto             res = new MultiAssistDto();
            List <Beneficiaries>       beneficiaryList;
            List <MultiAssistsVehicle> vehicleList;

            try {
                res.MultiAssist = _service.GetById(id);
                vehicleList     = new List <MultiAssistsVehicle>(res.MultiAssist.MultiAssistsVehicle);
                beneficiaryList = new List <Beneficiaries>(res.MultiAssist.Beneficiaries);
                vehicleList.ForEach((v) => {
                    v.MultiAssists = null;
                });
                beneficiaryList.ForEach((b) => {
                    b.MultiAssists = null;
                });
                res.MultiAssist.MultiAssistsVehicle = vehicleList;
                res.MultiAssist.Beneficiaries       = beneficiaryList;
                res.HealthPlan = res.MultiAssist.Cover.HealthPlan;
                res.MultiAssist.Cover.MultiAssists = null;
                res.HealthPlan.Covers            = null;
                res.MultiAssist.Cover.HealthPlan = null;
                return(Ok(res));
            } catch (System.Exception ex) {
                return(DefaultError(ex));
            }
        }
Пример #2
0
        public IActionResult Create([FromBody] MultiAssistDto payload)
        {
            try {
                int           cpId;
                ClientProduct clientProduct = new ClientProduct {
                    ClientId  = payload.ClientId,
                    ProductId = 2,                             //MULTI-ASSIST ID
                    Status    = 0,
                    CreatedAt = DateTime.Now
                };

                cpId = _clientProductService.Create(clientProduct);

                if (cpId > 0)
                {
                    payload.MultiAssist.ClientProductId = cpId;
                    _service.Create(payload.MultiAssist);
                    payload.MultiAssist.ClientProduct = null;
                }
                else
                {
                    return(BadRequest());
                }

                return(Ok(payload));
            } catch (System.Exception ex) {
                return(DefaultError(ex));
            }
        }
Пример #3
0
 public IActionResult Update([FromBody] MultiAssistDto payload)
 {
     try {
         this._service.Update(payload.MultiAssist);
         return(Ok());
     } catch (System.Exception ex) {
         return(DefaultError(ex));
     }
 }
Пример #4
0
        public IActionResult GetAll()
        {
            List <MultiAssistDto> multiAssistDtoList = new List <MultiAssistDto>();

            try {
                var multiAssist = _service.GetAll().ToList();
                multiAssist.ForEach((m) => {
                    if (m.Cover is Covers c)
                    {
                        var mdto = new MultiAssistDto {
                            MultiAssist = m,
                            Name        = c.Name
                        };
                        mdto.MultiAssist.Cover = null;
                        multiAssistDtoList.Add(mdto);
                    }
                });
            } catch (System.Exception ex) {
                return(DefaultError(ex));
            }
            return(Ok(multiAssistDtoList));
        }