public ActionResult Update(Guid invoiceSetupId, Guid id, InvoiceSetupItemApiModel invoiceSetupItemApiModel)
        {
            try
            {
                ApiResponse serviceResponse = this._invoiceSetupItemService.GetSingle(id);
                if (serviceResponse.IsSuccess() == false)
                {
                    return(new ObjectNotFoundResult(serviceResponse));
                }

                InvoiceSetupItem invoiceSetupItem = serviceResponse.GetData <InvoiceSetupItem>();
                _invoiceSetupItemMapper.Map(invoiceSetupItemApiModel, invoiceSetupItem);
                if (invoiceSetupItem.InvoiceSetupId == invoiceSetupId)
                {
                    serviceResponse = this._invoiceSetupItemService.Update(invoiceSetupItem);
                    return(SendResponse(serviceResponse));
                }
                else
                {
                    invoiceSetupItem.Type = 1;
                    serviceResponse       = this._invoiceSetupItemService.Add(invoiceSetupId, invoiceSetupItem);
                    return(SendResponse(serviceResponse, "InvoiceSetupItem"));
                }
            }
            catch (Exception ex)
            {
                return(new UnknownErrorResult(ex, base._errorEnabled));
            }
        }
        public List <InvoiceSetupItemApiModel> Map(ICollection <InvoiceSetupItem> invoiceSetupItemList)
        {
            List <InvoiceSetupItemApiModel> invoiceSetupItemApiModels = new List <InvoiceSetupItemApiModel>();

            foreach (var invoiceSetupItem in invoiceSetupItemList)
            {
                var invoiceSetupItemApiModel = new InvoiceSetupItemApiModel();
                Map(invoiceSetupItem, invoiceSetupItemApiModel);
                invoiceSetupItemApiModels.Add(invoiceSetupItemApiModel);
            }
            return(invoiceSetupItemApiModels);
        }
 public ActionResult Add(Guid invoiceSetupId, InvoiceSetupItemApiModel invoiceSetupItemApiModel)
 {
     try
     {
         var invoiceSetupItem = _invoiceSetupItemMapper.Map(invoiceSetupItemApiModel);
         var serviceResponse  = this._invoiceSetupItemService.Add(invoiceSetupId, invoiceSetupItem);
         return(SendResponse(serviceResponse, "InvoiceSetupItem"));
     }
     catch (Exception ex)
     {
         return(new UnknownErrorResult(ex, base._errorEnabled));
     }
 }
        public InvoiceSetupItem Map(InvoiceSetupItemApiModel invoiceSetupItemApiModel, InvoiceSetupItem invoiceSetupItem = null)
        {
            if (invoiceSetupItem == null)
            {
                invoiceSetupItem = new InvoiceSetupItem();
            }


            invoiceSetupItem.Description   = invoiceSetupItemApiModel.Description;
            invoiceSetupItem.ServiceId     = invoiceSetupItemApiModel.ItemId.ToGuid();
            invoiceSetupItem.ConsumptionId = invoiceSetupItemApiModel.ConsumptionId.ToNullableGuid();
            invoiceSetupItem.Amount        = invoiceSetupItemApiModel.Amount;
            return(invoiceSetupItem);
        }
        public InvoiceSetupItemApiModel Map(InvoiceSetupItem invoiceSetupItem, InvoiceSetupItemApiModel invoiceSetupItemApiModel = null)
        {
            if (invoiceSetupItemApiModel == null)
            {
                invoiceSetupItemApiModel = new InvoiceSetupItemApiModel();
            }
            string consumptionId   = "";
            string consumptionName = "";

            if (invoiceSetupItem.ConsumptionId != null)
            {
                consumptionId   = invoiceSetupItem.ConsumptionId.Value.ToString();
                consumptionName = invoiceSetupItem.Consumption.Description;
            }
            invoiceSetupItemApiModel.Id            = invoiceSetupItem.Id == Guid.Empty ? "" : invoiceSetupItem.Id.ToString();
            invoiceSetupItemApiModel.Description   = invoiceSetupItem.Description;
            invoiceSetupItemApiModel.ItemId        = invoiceSetupItem.ServiceId.ToString();
            invoiceSetupItemApiModel.ConsumptionId = consumptionId;
            invoiceSetupItemApiModel.Item          = invoiceSetupItem.Service.Name;
            invoiceSetupItemApiModel.Consumption   = consumptionName;
            invoiceSetupItemApiModel.Amount        = invoiceSetupItem.Amount;
            return(invoiceSetupItemApiModel);
        }