Exemple #1
0
        public ActionResult Detail(string materialid)
        {
            dtoProduct dto = new dtoProduct();

            dto = dal.getProduct(materialid);
            return(View(dto));
        }
Exemple #2
0
 public static Product ToProduct(dtoProduct dtoProduct)
 {
     if (dtoProduct == null)
     {
         return(null);
     }
     return(new Product()
     {
         Barcode = dtoProduct.Barcode, Company = dtoProduct.Company, CodeAlias = dtoProduct.CodeAlias, Size = dtoProduct.Size, Code = dtoProduct.Code, Alias = Converts.ToAlias(dtoProduct.Alias), ProductAlias = Converts.ToProductAliases(dtoProduct.ProductAlias), Src = dtoProduct.Src
     });
 }
Exemple #3
0
        //[Route("api/product")]
        public RequestResponse Post(dtoProduct product)
        {
            RequestResponse r = new RequestResponse();

            try
            {
                dtoProduct dtoProduct = product.Insert();
                r.Data    = dtoProduct;
                r.Message = "save product ok";
                r.Result  = true;
            }
            catch
            {
                r.Message = "problem saving product";
                r.Result  = false;
                r.Data    = null;
            }
            //זה מה שצריך לעבוד בסוף


            return(r);
        }
Exemple #4
0
        public dtoProduct getProduct(string id)
        {
            string           sql          = @"SELECT TOP(1) [Id] ,[Action],[EntityNumber],[IdocNumber],[ServiceId],[StatusId],[Data]
      ,[StatusMessage]
      ,[Type]
      ,[Created]
      ,[CreatedBy]
      ,[Modified]
      ,[ModifiedBy]
      ,[Version]
        FROM[jbsmstr].[scoMaster].[RawInterfaceData]
        WHERE Id = '" + id.ToString() + "'";
            List <dtoSite>   sites        = new List <dtoSite>();
            List <dtoUnit>   units        = new List <dtoUnit>();
            RawInterfaceData r            = db.Database.SqlQuery <RawInterfaceData>(sql).FirstOrDefault();
            string           materialdesc = "No Material Description";
            string           legacycode   = "No Legacy Code";
            string           pricingunit  = "No Pricing Unit";
            string           sapdocid     = "No SAP Doc ID";
            string           materialid   = "No Material ID";

            if (r.Data != null)
            {
                try
                {
                    Material_Master_Data result;
                    var serializer = new XmlSerializer(typeof(Material_Master_Data));

                    using (var reader = new StringReader(r.Data))
                    {
                        result = (Material_Master_Data)serializer.Deserialize(reader);
                    }


                    if (result.MaterialMasterGeneralData != null)
                    {
                        if (result.MaterialMasterGeneralData.LegacyCode != null)
                        {
                            legacycode = result.MaterialMasterGeneralData.LegacyCode.ToString();
                        }
                        if (result.MaterialMasterGeneralData.MaterialNumber != null)
                        {
                            materialid = result.MaterialMasterGeneralData.MaterialNumber.ToString();
                        }
                    }

                    if (result.SAPIDOCNumber != null)
                    {
                        sapdocid = result.SAPIDOCNumber;
                    }

                    if (result.MaterialMasterAlternateUoMDetails != null)
                    {
                        if (result.MaterialMasterAlternateUoMDetails.Count > 0)
                        {
                            foreach (Material_Master_DataMaterialMasterAlternateUoM u in result.MaterialMasterAlternateUoMDetails)
                            {
                                dtoUnit ui = new dtoUnit();
                                if (u.AlternateUoM != null)
                                {
                                    ui.pricingUM = u.AlternateUoM;
                                }
                                units.Add(ui);
                            }
                        }
                    }



                    if (result.MaterialMasterPlantDataDetails != null)
                    {
                        if (result.MaterialMasterPlantDataDetails.Count > 0)
                        {
                            foreach (Material_Master_DataMaterialMasterPlantData pd in result.MaterialMasterPlantDataDetails)
                            {
                                dtoSite s = new dtoSite();
                                if (pd.PlantCode != null)
                                {
                                    s.legacysitecode = pd.PlantCode;
                                    Plant pl = db.Plants.Where(i => i.plantcode == pd.PlantCode).FirstOrDefault();
                                    if (pl != null)
                                    {
                                        s.legacysitedesc = pl.plantdescription;
                                        s.sapsitecode    = pl.plantcode;
                                    }
                                    sites.Add(s);
                                }
                            }
                            legacycode = result.MaterialMasterGeneralData.LegacyCode.ToString();
                        }
                    }


                    if (result.MaterialMasterShortTextsDetails.MaterialMasterShortTexts != null)
                    {
                        materialdesc = result.MaterialMasterShortTextsDetails.MaterialMasterShortTexts.MaterialDescription.ToString();
                    }
                    r.Data = materialdesc + " " + legacycode;
                }
                catch (Exception ex)
                {
                    string issue = ex.ToString();
                    r.Data = "Problem";
                }
            }

            dtoProduct p = new dtoProduct();

            p.sites       = sites;
            p.units       = units;
            p.materialid  = materialid;
            p.recguid     = r.Id.ToString();
            p.legacycode  = legacycode;
            p.description = materialdesc;
            p.sapdocid    = sapdocid;

            return(p);
        }