Exemple #1
0
        public Models.AirFilter Post(Models.AirFilter airFilter)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
            }
            if (airFilter.AilFilterId > 0)
            {
                #region Update Record
                Models.AirFilter airFilterDbVersion = GetAirFilterById(airFilter.AilFilterId);
                airFilterDbVersion.AirFilterName  = airFilter.AirFilterName;
                airFilterDbVersion.AirFilterPrice = airFilter.AirFilterPrice;
                DbSet.AddOrUpdate(airFilterDbVersion);
                db.SaveChanges();

                #endregion
            }
            else
            {
                #region Add New Record

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

                #endregion
            }
            return(GetAirFilterById(airFilter.AilFilterId));
        }
 public Models.AirFilter Post(Models.AirFilter oil)
 {
     if (!ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(_airFilterService.Save(oil.CreateFrom()).CreateFrom());
 }
Exemple #3
0
 /// <summary>
 ///  Create entity from web model
 /// </summary>
 public static MainDomain.AirFilter CreateFrom(this Models.AirFilter source)
 {
     return(new MainDomain.AirFilter
     {
         AilFilterId = source.AilFilterId,
         AirFilterName = source.AirFilterName,
         AirFilterPrice = source.AirFilterPrice
     });
 }