Exemplo n.º 1
0
        public IHttpActionResult SaveLookUpValue(ModelForMasters.ProductLU data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            base.PortalEntities.Products.Add(new Product {
                PID               = data.PID,
                ProdCode          = data.ProdCode,
                ProdDesc          = data.ProdDesc,
                CatID             = data.CatID,
                ProdType          = data.ProdType,
                RawMaterial       = data.RawMaterial,
                Wastage           = data.Wastage,
                EmbededWithStones = data.EmbededWithStones,
                NoOfPieces        = data.NoOfPieces,
                WeightPerPiece    = data.WeightPerPiece,
                PurchasePerPiece  = data.PurchasePerPiece,
                MakingCharge      = data.MakingCharge,
                Directbilling     = data.Directbilling,
                PerPiecePrice     = data.PerPiecePrice
            });
            base.PortalEntities.SaveChanges();

            return(Ok(data));
        }
Exemplo n.º 2
0
        public IHttpActionResult UpdateLookUpValue(ModelForMasters.ProductLU data)
        {
            if (data != null)
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var record = this.PortalEntities.Products.Where(x => x.PID == data.PID).First();
                record.PID               = data.PID;
                record.ProdCode          = data.ProdCode;
                record.ProdDesc          = data.ProdDesc;
                record.CatID             = data.CatID;
                record.ProdType          = data.ProdType;
                record.RawMaterial       = data.RawMaterial;
                record.Wastage           = data.Wastage;
                record.EmbededWithStones = data.EmbededWithStones;
                record.NoOfPieces        = data.NoOfPieces;
                record.WeightPerPiece    = data.WeightPerPiece;
                record.PurchasePerPiece  = data.PurchasePerPiece;
                record.MakingCharge      = data.MakingCharge;
                record.Directbilling     = data.Directbilling;
                record.PerPiecePrice     = data.PerPiecePrice;

                try
                {
                    this.PortalEntities.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
            }
            return(Ok(data));
        }