public ActionResult Detail(int?Id)
        {
            var infoPartyA = InfoPartyARepository.GetvwInfoPartyAById(Id.Value);

            if (infoPartyA != null && infoPartyA.IsDeleted != true)
            {
                var model = new InfoPartyAViewModel();
                AutoMapper.Mapper.Map(infoPartyA, model);
                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult Detail(int?Id, string TransactionCode)
        {
            var Contract = new Contract();

            if (Id != null)
            {
                Contract = ContractRepository.GetContractById(Id.Value);
            }
            if (!string.IsNullOrEmpty(TransactionCode))
            {
                Contract = ContractRepository.GetContractByTransactionCode(TransactionCode);
            }


            if (Contract != null && Contract.IsDeleted != true)
            {
                var model = new ContractViewModel();
                AutoMapper.Mapper.Map(Contract, model);

                if (Contract.Type == "ContractLease")
                {
                    string[] s = model.IdTypeContract.Split('_');
                    string   idTypecontract = s[s.Length - 1];
                    var      ContractLease  = contractLeaseRepository.GetvwContractLeaseById(Convert.ToInt32(idTypecontract));
                    model.ContractLeaseModel = new ContractLeaseViewModel();
                    AutoMapper.Mapper.Map(ContractLease, model.ContractLeaseModel);
                }
                else
                if (Contract.Type == "ContractSell")
                {
                    string[] s = model.IdTypeContract.Split('_');
                    string   idTypecontract = s[s.Length - 1];
                    var      ContractSell   = contractSellRepository.GetvwContractSellById(Convert.ToInt32(idTypecontract));
                    model.ContractSellModel = new ContractSellViewModel();
                    AutoMapper.Mapper.Map(ContractSell, model.ContractSellModel);
                }
                var infoA = infoPartyARepository.GetvwInfoPartyAById(model.InfoPartyAId.Value);
                model.InfoPartyAViewModel = new InfoPartyAViewModel();
                AutoMapper.Mapper.Map(infoA, model.InfoPartyAViewModel);

                var customer = customerRepository.GetCustomerById(model.CustomerId.Value);
                model.CustomerViewModel = new CustomerViewModel();
                AutoMapper.Mapper.Map(customer, model.CustomerViewModel);

                var contact = contactRepository.GetAllvwContactByCustomerId(customer.Id);
                model.contactList = contact.Select(item => new ContactViewModel
                {
                    Id            = item.Id,
                    CreatedUserId = item.CreatedUserId,
                    //CreatedUserName = item.CreatedUserName,
                    CreatedDate    = item.CreatedDate,
                    ModifiedUserId = item.ModifiedUserId,
                    //ModifiedUserName = item.ModifiedUserName,
                    ModifiedDate = item.ModifiedDate,
                    Address      = item.Address,
                    Birthday     = item.Birthday,
                    CityId       = item.CityId,
                    CustomerId   = item.CustomerId,
                    DistrictId   = item.DistrictId,
                    Email        = item.Email,
                    FirstName    = item.FirstName,
                    FullName     = item.FirstName + item.LastName,
                    Gender       = item.Gender,
                    LastName     = item.LastName,
                    Mobile       = item.Mobile,
                    Note         = item.Note,
                    Phone        = item.Phone,
                    WardId       = item.WardId,
                    DistrictName = item.DistrictName,
                    GenderName   = item.GenderName,
                    ProvinceName = item.ProvinceName,
                    WardName     = item.WardName
                }).OrderByDescending(m => m.ModifiedDate);
                ViewBag.Type = model.Type;
                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }