Exemple #1
0
        public ActionResult Edit(int id)
        {
            //Get ClientSubUnitTelephony
            ClientSubUnitClientDefinedReference clientSubUnitClientDefinedReference = new ClientSubUnitClientDefinedReference();

            clientSubUnitClientDefinedReference = clientSubUnitCDRRepository.GetClientSubUnitCDR(id);

            //Check Exists
            if (clientSubUnitClientDefinedReference == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToClientSubUnit(clientSubUnitClientDefinedReference.ClientSubUnitGuid))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ClientSubUnitCDRVM clientSubUnitCDRVM = new ClientSubUnitCDRVM();


            CreditCard           creditCard           = new CreditCard();
            CreditCardRepository creditCardRepository = new CreditCardRepository();

            if (clientSubUnitClientDefinedReference.CreditCardId == null)
            {
                clientSubUnitClientDefinedReference.CreditCard = creditCard;
            }
            else
            {
                creditCard = creditCardRepository.GetCreditCard((int)clientSubUnitClientDefinedReference.CreditCardId, false);
                clientSubUnitCDRVM.CreditCardValidTo = creditCard.CreditCardValidTo;
            }

            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnitCDRVM.ClientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitClientDefinedReference.ClientSubUnitGuid);

            //Add MaskedCreditCardNumber and CreditCardHolderName into Select List
            CreditCardClientSubUnitRepository creditCardClientSubUnitRepository = new CreditCardClientSubUnitRepository();
            List <CreditCard>     creditCards    = creditCardClientSubUnitRepository.GetAllCreditCardsBySubUnit(clientSubUnitClientDefinedReference.ClientSubUnitGuid).ToList();
            List <SelectListItem> creditCardList = new List <SelectListItem>();

            foreach (CreditCard creditCardItem in creditCards)
            {
                creditCardList.Add(new SelectListItem
                {
                    Value = creditCardItem.CreditCardId.ToString(),
                    Text  = string.Format("{0}\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0{1}", creditCardItem.MaskedCreditCardNumber, creditCardItem.CreditCardHolderName)                    //Space out items
                });
            }
            clientSubUnitCDRVM.CreditCardSelectList = new SelectList(creditCardList, "Value", "Text");

            ClientSubUnitClientAccountRepository clientSubUnitClientAccountRepository = new ClientSubUnitClientAccountRepository();
            string modifiedClientAccountNumber = clientSubUnitClientDefinedReference.ClientAccountNumber + "|" + clientSubUnitClientDefinedReference.SourceSystemCode;

            clientSubUnitCDRVM.ClientAccountSelectList = clientSubUnitClientAccountRepository.GetClientAccountsBySubUnit(clientSubUnitClientDefinedReference.ClientSubUnitGuid, modifiedClientAccountNumber.ToString());

            clientSubUnitClientDefinedReference.ClientAccountNumberSourceSystemCode = modifiedClientAccountNumber;
            clientSubUnitCDRVM.ClientSubUnitClientDefinedReference = clientSubUnitClientDefinedReference;

            //Show Create Form
            return(View(clientSubUnitCDRVM));
        }
Exemple #2
0
        public ActionResult Edit(ClientSubUnitCDRVM clientSubUnitCDRVM)
        {
            if (!ModelState.IsValid)
            {
                string clientSubUnitGuid = clientSubUnitCDRVM.ClientSubUnit.ClientSubUnitGuid;

                //Get ClientSubUnit
                ClientSubUnit clientSubUnit = new ClientSubUnit();
                clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitGuid);

                ClientTopUnit           clientTopUnit           = new ClientTopUnit();
                ClientTopUnitRepository clientTopUnitRepository = new ClientTopUnitRepository();
                clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientSubUnit.ClientTopUnitGuid);

                clientSubUnit.ClientTopUnit      = clientTopUnit;
                clientSubUnitCDRVM.ClientSubUnit = clientSubUnit;



                clientSubUnitCDRVM.ClientSubUnit = clientSubUnit;

                CreditCardClientSubUnitRepository creditCardClientSubUnitRepository = new CreditCardClientSubUnitRepository();
                clientSubUnitCDRVM.CreditCardSelectList = new SelectList(creditCardClientSubUnitRepository.GetAllCreditCardsBySubUnit(clientSubUnitGuid).ToList(), "CreditCardId", "MaskedCreditCardNumber");

                ClientSubUnitClientAccountRepository clientSubUnitClientAccountRepository = new ClientSubUnitClientAccountRepository();
                clientSubUnitCDRVM.ClientAccountSelectList = clientSubUnitClientAccountRepository.GetClientAccountsBySubUnit(clientSubUnitGuid, "");

                //ClientTopUnitRepository clientTopUnitRepository = new ClientTopUnitRepository();
                //clientSubUnitCDRVM.ClientSubUnit.ClientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientSubUnitCDRVM.ClientSubUnit.ClientSubUnitGuid);
                return(View(clientSubUnitCDRVM));
            }

            CreditCard creditCard   = new CreditCard();
            int?       creditCardId = clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.CreditCardId;

            if (creditCardId != null)
            {
                creditCard = creditCardRepository.GetCreditCard((int)creditCardId, false);
            }

            ClientAccount clientAccount       = new ClientAccount();
            string        clientAccountNumber = null;
            string        sourceSystemCode    = null;

            if (!String.IsNullOrEmpty(clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.ClientAccountNumberSourceSystemCode))
            {
                clientAccountNumber = clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.ClientAccountNumberSourceSystemCode.Split(new[] { '|' })[0];
                sourceSystemCode    = clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.ClientAccountNumberSourceSystemCode.Split(new[] { '|' })[1];
                clientAccount       = clientAccountRepository.GetClientAccount(clientAccountNumber, sourceSystemCode);
            }

            //Check Exists (at least one
            if (creditCard == null && clientAccount == null)
            {
                ViewData["ActionMethod"] = "CreatePost";
                return(View("RecordDoesNotExistError"));
            }

            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToClientSubUnit(clientSubUnitCDRVM.ClientSubUnit.ClientSubUnitGuid))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ClientSubUnitClientDefinedReference clientSubUnitClientDefinedReference = new ClientSubUnitClientDefinedReference();

            clientSubUnitClientDefinedReference.ClientSubUnitGuid   = clientSubUnitCDRVM.ClientSubUnit.ClientSubUnitGuid;
            clientSubUnitClientDefinedReference.Value               = clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.Value;
            clientSubUnitClientDefinedReference.VersionNumber       = clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.VersionNumber;
            clientSubUnitClientDefinedReference.ClientAccountNumber = clientAccountNumber;
            clientSubUnitClientDefinedReference.SourceSystemCode    = sourceSystemCode;
            if (creditCardId != null)
            {
                clientSubUnitClientDefinedReference.CreditCardId = creditCard.CreditCardId;
            }
            clientSubUnitClientDefinedReference.ClientSubUnitClientDefinedReferenceId = clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.ClientSubUnitClientDefinedReferenceId;
            clientSubUnitClientDefinedReference.VersionNumber = clientSubUnitCDRVM.ClientSubUnitClientDefinedReference.VersionNumber;



            try
            {
                clientSubUnitCDRRepository.Edit(clientSubUnitClientDefinedReference);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }



            return(RedirectToAction("List", new { id = clientSubUnitCDRVM.ClientSubUnit.ClientSubUnitGuid }));
        }
Exemple #3
0
        public ActionResult Create(ClientSubUnitCDRsVM clientSubUnitCDRsVM, string btnSubmit)
        {
            string clientSubUnitGuid    = clientSubUnitCDRsVM.ClientSubUnitGuid;
            string displayName          = clientSubUnitCDRsVM.DisplayName;
            string relatedToDisplayName = clientSubUnitCDRsVM.RelatedToDisplayName ?? "";

            if (btnSubmit == "Import")
            {
                return(RedirectToAction("ImportStep1", new { id = clientSubUnitGuid, displayName = displayName, relatedToDisplayName = relatedToDisplayName }));
            }

            //Get ClientSubUnit
            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitGuid);

            //Check Exists
            if (clientSubUnit == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }



            //Check Exists
            //if (clientdefinedReferenceItem2 == null)
            //{
            //    ViewData["ActionMethod"] = "CreateGet";
            //    return View("RecordDoesNotExistError");
            //}


            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToClientSubUnit(clientSubUnitGuid))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ClientSubUnitCDRVM clientSubUnitCDRVM = new ClientSubUnitCDRVM();

            clientSubUnitCDRVM.ClientSubUnit = clientSubUnit;

            //Get ClientSubUnit/ClientDefinedReferenceItem
            ClientDefinedReferenceItem clientdefinedReferenceItem2 = new ClientDefinedReferenceItem();
            //if(string.IsNullOrEmpty(displayName)){
            //clientdefinedReferenceItem2. = ClientDefinedReferenceItemId;// clientDefinedReferenceItemRepository.GetCSUClientDefinedReferenceItemByCDRId(clientSubUnitGuid, ClientDefinedReferenceItemId);
            //     ClientSubUnitClientDefinedReference clientSubUnitClientDefinedReference = new ClientSubUnitClientDefinedReference();
            //     clientSubUnitClientDefinedReference.DisplayName = displayName;
            //     clientSubUnitCDRVM.ClientSubUnitClientDefinedReference = clientSubUnitClientDefinedReference;
            //}else{

            //   clientdefinedReferenceItem2 = clientDefinedReferenceItemRepository.GetCSUClientDefinedReferenceItem(clientSubUnitGuid,displayName);
            //   clientSubUnitCDRVM.ClientDefinedReferenceItemId = clientdefinedReferenceItem2.ClientDefinedReferenceItemId;
            //}

            //Add MaskedCreditCardNumber and CreditCardHolderName into Select List
            CreditCardClientSubUnitRepository creditCardClientSubUnitRepository = new CreditCardClientSubUnitRepository();
            List <CreditCard>     creditCards    = creditCardClientSubUnitRepository.GetAllCreditCardsBySubUnit(clientSubUnitGuid).ToList();
            List <SelectListItem> creditCardList = new List <SelectListItem>();

            foreach (CreditCard creditCardItem in creditCards)
            {
                creditCardList.Add(new SelectListItem
                {
                    Value = creditCardItem.CreditCardId.ToString(),
                    Text  = string.Format("{0}\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0{1}", creditCardItem.MaskedCreditCardNumber, creditCardItem.CreditCardHolderName)                    //Space out items
                });
            }
            clientSubUnitCDRVM.CreditCardSelectList = new SelectList(creditCardList, "Value", "Text");

            ClientSubUnitClientAccountRepository clientSubUnitClientAccountRepository = new ClientSubUnitClientAccountRepository();

            clientSubUnitCDRVM.ClientAccountSelectList = clientSubUnitClientAccountRepository.GetClientAccountsBySubUnit(clientSubUnitGuid, "");
            clientSubUnitCDRVM.CreditCardValidTo       = null;

            //Show Create Form
            return(View(clientSubUnitCDRVM));
        }