Ejemplo n.º 1
0
        public static ComponentMaster Update(ComponentMaster componentMaster)
        {
            try
            {
                using Repository <ComponentMaster> repo = new Repository <ComponentMaster>();
                repo.ComponentMaster.Update(componentMaster);
                if (repo.SaveChanges() > 0)
                {
                    return(componentMaster);
                }

                return(null);
            }
            catch { throw; }
        }
Ejemplo n.º 2
0
        public IActionResult RegisterComponent([FromBody] ComponentMaster componentMaster)
        {
            if (componentMaster == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(componentMaster)} cannot be null"
                }));
            }
            else
            {
                if (ComponentMasterHelper.GetComponents(componentMaster.ComponentCode) != null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Code =" + componentMaster.ComponentCode + " is already Exists,Please Use Another Code"
                    }));
                }

                try
                {
                    APIResponse apiResponse = null;
                    var         result      = ComponentMasterHelper.Register(componentMaster);
                    if (result != null)
                    {
                        apiResponse = new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = result
                        };
                    }
                    else
                    {
                        apiResponse = new APIResponse()
                        {
                            status = APIStatus.FAIL.ToString(), response = "Registration Failed."
                        };
                    }

                    return(Ok(apiResponse));
                }
                catch (Exception ex)
                {
                    return(Ok(new APIResponse {
                        status = APIStatus.FAIL.ToString(), response = ex.Message
                    }));
                }
            }
        }
Ejemplo n.º 3
0
        public static ComponentMaster Register(ComponentMaster componentMaster)
        {
            try
            {
                using Repository <ComponentMaster> repo = new Repository <ComponentMaster>();
                componentMaster.Active = "Y";
                repo.ComponentMaster.Add(componentMaster);
                if (repo.SaveChanges() > 0)
                {
                    return(componentMaster);
                }

                return(null);
            }
            catch { throw; }
        }
Ejemplo n.º 4
0
        public IActionResult UpdateComponent([FromBody] ComponentMaster componentMaster)
        {
            if (componentMaster == null)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.PASS.ToString(), response = $"{nameof(componentMaster)} cannot be null"
                }));
            }
            try
            {
                APIResponse apiResponse = null;

                ComponentMaster result = ComponentMasterHelper.Update(componentMaster);
                if (result != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = result
                    };
                }
                else
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Updation Failed."
                    };
                }
                return(Ok(apiResponse));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }
Ejemplo n.º 5
0
        public async Task <ComponentPartnerVM> Build()
        {
            _componentPartnerVm = new ComponentPartnerVM();

            ComponentMaster componentMaster = _ampRepository.GetComponent(_ComponentID);
            ProjectMaster   projectMaster   = _ampRepository.GetProject(componentMaster.ProjectID);

            //Get the chain from DB
            List <DeliveryChain> deliveryChains = _ampRepository.GetDeliveryChainsByComponent(_ComponentID).OrderBy(x => x.ChainID).ToList();

            //New Delivery Chain list object
            List <DeliveryChainListVM> deliveryChainListVms;

            //Map Chain to VM
            Mapper.CreateMap <DeliveryChain, DeliveryChainListVM>();
            deliveryChainListVms = Mapper.Map <List <DeliveryChain>, List <DeliveryChainListVM> >(deliveryChains);

            //Get Descriptions for all
            List <int>    listOfPartners  = new List <int>();
            List <string> listOfSuppliers = new List <string>();


            foreach (DeliveryChainListVM chain in deliveryChainListVms)
            {
                //Check Parent
                if (chain.ParentType == "P")
                {
                    listOfPartners.Add(Int32.Parse(chain.ParentID));
                }
                if (chain.ParentType == "S")
                {
                    listOfSuppliers.Add(chain.ParentID.ToString());
                }

                //Check Child
                if (chain.ChildType == "P")
                {
                    listOfPartners.Add(Int32.Parse(chain.ChildID));
                }
                if (chain.ChildType == "S")
                {
                    listOfSuppliers.Add(chain.ChildID.ToString());
                }
            }

            //Get List of IDs and Names from PartnerMaster based on list of Partners
            List <PartnerMaster> partnerMasters = _ampRepository.GetDeliveryChainsByIDList(listOfPartners);

            //

            //Get List of IDs and Names from ARIES Suppliers based on list of Suppliers
            IEnumerable <SupplierVM> SupplierVms = await _AriesService.GetSuppliers(listOfSuppliers, "");


            //Map description
            foreach (DeliveryChainListVM chainList in deliveryChainListVms)
            {
                if (chainList.ParentType == "P")
                {
                    foreach (PartnerMaster partners in partnerMasters)
                    {
                        if (Int32.Parse(chainList.ParentID) == partners.PartnerID)
                        {
                            chainList.ParentName = partners.PartnerName;
                        }
                    }
                }
                if (chainList.ParentType == "S")
                {
                    foreach (SupplierVM suppliers in SupplierVms)
                    {
                        if (Int32.Parse(chainList.ParentID) == Int32.Parse(suppliers.SupplierID))
                        {
                            chainList.ParentName = suppliers.SupplierName;
                        }
                    }
                }

                //Check Child
                if (chainList.ChildType == "P")
                {
                    foreach (PartnerMaster partners in partnerMasters)
                    {
                        if (Int32.Parse(chainList.ChildID) == partners.PartnerID)
                        {
                            chainList.ChildName = partners.PartnerName;
                        }
                    }
                }
                if (chainList.ChildType == "S")
                {
                    foreach (SupplierVM suppliers in SupplierVms)
                    {
                        if (Int32.Parse(chainList.ChildID) == Int32.Parse(suppliers.SupplierID))
                        {
                            chainList.ChildName = suppliers.SupplierName;
                        }
                    }
                }
            }

            List <PartnersTier1> tier1Partners = await _AriesService.GetTier1Partners(_ComponentID);

            DeliveryChainsVM deliveryChainsVM = new DeliveryChainsVM();

            //Here we would need to map in all the descriptions. 4 loops? 2 for each ID type and 2 for parent and child.
            //We will need 2 get methods. They will take a list of ID's and return ID's and names, one for partner and one for supplier.
            //Then we can set deliveryChains to the view model.

            deliveryChainsVM.deliveryChains      = deliveryChainListVms;
            _componentPartnerVm.DeliveryChainsVm = deliveryChainsVM;
            _componentPartnerVm.Tier1Partners    = tier1Partners;

            DeliveryChainVM deliveryChainVm = new DeliveryChainVM();

            _componentPartnerVm.DeliveryChainsVm = deliveryChainsVM;

            return(_componentPartnerVm);
        }