Exemple #1
0
        public bool AddAddressHistory(AdressHistory address)
        {
            _db.AdressHistories.Add(address);
            int Result = _db.SaveChanges();

            if (Result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public bool updqateAddressHistory(AdressHistory address)
        {
            AdressHistory DTO = _db.AdressHistories.Where(m => m.Party == address.Party).FirstOrDefault();

            DTO.EnglisgAddress = address.EnglisgAddress;
            DTO.UrduAddress    = address.UrduAddress;

            int Result = _db.SaveChanges();

            if (Result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        public async Task <Response> GetAddressHistory(int party)
        {
            try
            {
                AdressHistory DTO = await _db.AdressHistories.Where(x => x.Party == party).FirstOrDefaultAsync();

                AdressHistoryVM address = new AdressHistoryVM();
                if (DTO != null)
                {
                    address.EnglisgAddress = DTO.EnglisgAddress;
                    address.UrduAddress    = DTO.UrduAddress;

                    return(GenericResponses <AdressHistoryVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, address));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Exemple #4
0
        public async Task <ActionResult> AddDo(DorderVM dorder, FormCollection frm)
        {
            int     saveCopy           = Convert.ToInt32(frm["SaveCopy"]);
            decimal lastDoNumber       = 0;
            decimal lastContractNumber = 0;
            double  totalQty           = 0;
            int     party = (int)dorder.Party;

            if (saveCopy == 1)
            {
                dorder.EcomID      = (int)Session["Comp"];
                dorder.CreatedOn   = DateTime.Today;
                lastDoNumber       = (decimal)dorder.DoNumber;
                lastContractNumber = (decimal)dorder.ContractNumber;
                Response reslut = await _Repository.AddDo(dorder);

                totalQty = (double)dorder.Weight;
                if (!reslut.IsError)
                {
                    ISettingRepository _setting = new SettingRepository();
                    _setting.UpdateDoAutoIncrement(dorder.autoincrement);
                    _setting.UpdateLastContractNumber((decimal)dorder.ContractNumber);
                    _setting.UpdateLastDoNumber((lastDoNumber + 1));


                    IContractRespository _contract = new ContractRepository();
                    ContractVM           contract  = new ContractVM();
                    contract.Party        = party;
                    contract.PartyName    = dorder.PartyName;
                    contract.TotatQty     = totalQty;
                    contract.Unit         = dorder.Unit;
                    contract.EcomID       = (int)Session["Comp"];
                    contract.CreatedOn    = DateTime.Today;
                    contract.ContractType = dorder.ContractType;
                    contract.ContractNo   = dorder.ContractNumber;
                    if (_contract.isInsertable(contract))
                    {
                        await _contract.AddContract(contract);
                    }
                    else
                    {
                        await _contract.UpdateContractQty(contract);
                    }

                    IAddressHistoryRepository _addresHistory = new AddressHistoryRepository();
                    AdressHistory             addressHistory = new AdressHistory();

                    addressHistory.Party          = dorder.Party;
                    addressHistory.EnglisgAddress = dorder.AddressEng;
                    addressHistory.UrduAddress    = dorder.AddressUrd;

                    if (_addresHistory.isInsertable((int)addressHistory.Party))
                    {
                        _addresHistory.AddAddressHistory(addressHistory);
                    }

                    else
                    {
                        _addresHistory.updqateAddressHistory(addressHistory);
                    }
                }
            }

            else
            {
                lastDoNumber = (decimal)dorder.DoNumber;
                for (int i = 0; i < saveCopy; i++)
                {
                    dorder.EcomID      = (int)Session["Comp"];
                    dorder.CreatedOn   = DateTime.Today;
                    dorder.DoNumber    = lastDoNumber;
                    lastContractNumber = (decimal)dorder.ContractNumber;
                    Response reslutloop = await _Repository.AddDo(dorder);

                    totalQty = totalQty + (double)dorder.Weight;
                    lastDoNumber++;
                }

                ISettingRepository _setting = new SettingRepository();
                _setting.UpdateDoAutoIncrement(dorder.autoincrement);
                _setting.UpdateLastContractNumber((decimal)dorder.ContractNumber);
                _setting.UpdateLastDoNumber((lastDoNumber));

                IContractRespository _contract = new ContractRepository();
                ContractVM           contract  = new ContractVM();
                contract.Party        = party;
                contract.PartyName    = dorder.PartyName;
                contract.TotatQty     = totalQty;
                contract.Unit         = dorder.Unit;
                contract.EcomID       = (int)Session["Comp"];
                contract.CreatedOn    = DateTime.Today;
                contract.ContractType = dorder.ContractType;
                contract.ContractNo   = dorder.ContractNumber;

                if (_contract.isInsertable(contract))
                {
                    await _contract.AddContract(contract);
                }
                else
                {
                    await _contract.UpdateContractQty(contract);
                }

                IAddressHistoryRepository _addresHistory = new AddressHistoryRepository();
                AdressHistory             addressHistory = new AdressHistory();

                addressHistory.Party          = dorder.Party;
                addressHistory.EnglisgAddress = dorder.AddressEng;
                addressHistory.UrduAddress    = dorder.AddressUrd;

                if (_addresHistory.isInsertable((int)addressHistory.Party))
                {
                    _addresHistory.AddAddressHistory(addressHistory);
                }

                else
                {
                    _addresHistory.updqateAddressHistory(addressHistory);
                }
            }

            return(RedirectToAction("Index"));
        }