public Models.BrakeOil Post(Models.BrakeOil brakeOil)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
            }
            if (brakeOil.BrakeOilId > 0)
            {
                #region Update Record
                Models.BrakeOil dbVersion = GetBrakeOilById(brakeOil.BrakeOilId);
                dbVersion.BrakeOilName  = brakeOil.BrakeOilName;
                dbVersion.BrakeOilPrice = brakeOil.BrakeOilPrice;
                DbSet.AddOrUpdate(brakeOil);
                db.SaveChanges();

                #endregion
            }
            else
            {
                #region Add New Record

                DbSet.Add(brakeOil);
                db.SaveChanges();

                #endregion
            }
            return(GetBrakeOilById(brakeOil.BrakeOilId));
        }
Exemple #2
0
 /// <summary>
 ///  Create entity from web model
 /// </summary>
 public static MainDomain.BrakeOil CreateFrom(this Models.BrakeOil source)
 {
     return(new MainDomain.BrakeOil
     {
         BrakeOilId = source.BrakeOilId,
         BrakeOilCompanyName = source.BrakeOilCompanyName,
         BrakeOilName = source.BrakeOilName,
         BrakeOilPrice = source.BrakeOilPrice
     });
 }