예제 #1
0
        public ActionResult AddClientBilling(ClientBilling _ClientBilling, ClientBillingRetailRate _ClientBillingRetailRate, ClientBillingWholesaleRate _ClientBillingWholesaleRate)
        {
            try
            {
                int      _ClientBillingID = 0;
                string[] _Ids             = new string[4];
                if (_ClientBilling.ClientBillingID > 0)
                {
                    _Ids[0] = GlobalConst.Mode.Update;

                    if (_ClientBilling.ClientAttentionToID != 3)
                    {
                        _ClientBilling.ClientAttentionToFreeText = null;
                    }

                    _ClientBillingID = _iClientService.updateClientBilling(Mapper.Map <MMC.MMCService.ClientService.ClientBilling>(_ClientBilling));

                    _Ids[1] = _ClientBilling.ClientBillingID.ToString();;

                    _ClientBillingRetailRate.ClientBillingID = _ClientBilling.ClientBillingID;
                    _ClientBillingRetailRate.CreatedBy       = MMCUser.UserId;
                    _ClientBillingRetailRate.CreatedOn       = System.DateTime.Now;

                    _Ids[2] = _ClientBillingRetailRate.ClientBillingRetailRateID.ToString();

                    _iClientService.updateClientBillingRetailRate(Mapper.Map <MMC.MMCService.ClientService.ClientBillingRetailRate>(_ClientBillingRetailRate));



                    if (_ClientBilling.ClientIsPrivateLabel == true)
                    {
                        _ClientBillingWholesaleRate.ClientBillingID = _ClientBilling.ClientBillingID;
                        _ClientBillingWholesaleRate.CreatedBy       = MMCUser.UserId;
                        _ClientBillingWholesaleRate.CreatedOn       = System.DateTime.Now;
                        _Ids[3] = _ClientBillingWholesaleRate.ClientBillingWholesaleRateID.ToString();
                        _iClientService.updateClientBillingWholesaleRate(Mapper.Map <MMC.MMCService.ClientService.ClientBillingWholesaleRate>(_ClientBillingWholesaleRate));
                    }
                    else
                    {
                        if (_ClientBillingWholesaleRate.ClientBillingWholesaleRateID > 0)
                        {
                            _iClientService.deleteClientBillingWholesaleRate(_ClientBillingWholesaleRate.ClientBillingWholesaleRateID);
                        }
                        // delete the Client Private Label
                        _iClientService.deleteClientPrivateLabelByClientID(_ClientBilling.ClientID);
                    }
                }
                else
                {
                    _Ids[0] = GlobalConst.Mode.Add;

                    if (_ClientBilling.ClientAttentionToID != 3)
                    {
                        _ClientBilling.ClientAttentionToFreeText = null;
                    }

                    _ClientBilling.ClientBillingID = _iClientService.addClientBilling(Mapper.Map <MMC.MMCService.ClientService.ClientBilling>(_ClientBilling));


                    _Ids[1] = _ClientBilling.ClientBillingID.ToString();

                    _ClientBillingRetailRate.ClientBillingID = _ClientBilling.ClientBillingID;
                    _ClientBillingRetailRate.CreatedBy       = MMCUser.UserId;
                    _ClientBillingRetailRate.CreatedOn       = System.DateTime.Now;

                    _ClientBillingRetailRate.ClientBillingRetailRateID = _iClientService.addClientBillingRetailRate(Mapper.Map <MMC.MMCService.ClientService.ClientBillingRetailRate>(_ClientBillingRetailRate));

                    _Ids[2] = _ClientBillingRetailRate.ClientBillingRetailRateID.ToString();
                    if (_ClientBilling.ClientIsPrivateLabel == true)
                    {
                        _ClientBillingWholesaleRate.ClientBillingID = _ClientBilling.ClientBillingID;
                        _ClientBillingWholesaleRate.CreatedBy       = MMCUser.UserId;
                        _ClientBillingWholesaleRate.CreatedOn       = System.DateTime.Now;

                        _ClientBillingWholesaleRate.ClientBillingWholesaleRateID = _iClientService.addClientBillingWholesaleRate(Mapper.Map <MMC.MMCService.ClientService.ClientBillingWholesaleRate>(_ClientBillingWholesaleRate));
                        _Ids[3] = _ClientBillingWholesaleRate.ClientBillingWholesaleRateID.ToString();
                    }
                }
                return(Json(_Ids, GlobalConst.ContentTypes.TextHtml));
            }
            catch
            {
                return(Json(0));
            }
        }