public bool Edit( int id, MakeType make, string model, decimal price, int quantity, int minShutterSpeed, int maxShutterSpeed, MinIsoType minIso, int maxIso, bool isFullFrame, string videoResolution, int lightMetering, string description, string imageUrl) { Camera camera = this.dbContext .Cameras .Find(id); if (camera == null) { return(false); } camera.Make = make; camera.Model = model; camera.Price = price; camera.Quantity = quantity; camera.MinShutterSpeed = minShutterSpeed; camera.MaxShutterSpeed = maxShutterSpeed; camera.MinIso = minIso; camera.MaxIso = maxIso; camera.IsFullFrame = isFullFrame; camera.VideoResolution = videoResolution; camera.LightMetering = (LightMeteringType)lightMetering; camera.Description = description; camera.ImageUrl = imageUrl; this.dbContext.SaveChanges(); return(true); }
public void Add( MakeType make, string model, decimal price, int quantity, int minShutterSpeed, int maxShutterSpeed, MinIsoType minIso, int maxIso, bool isFullFrame, string videoResolution, int lightMetering, string description, string imageUrl, string userId) { this.dbContext .Cameras .Add(new Camera { Make = make, Model = model, Price = price, Quantity = quantity, MinShutterSpeed = minShutterSpeed, MaxShutterSpeed = maxShutterSpeed, MinIso = minIso, MaxIso = maxIso, IsFullFrame = isFullFrame, VideoResolution = videoResolution, LightMetering = (LightMeteringType)lightMetering, Description = description, ImageUrl = imageUrl, UserId = userId }); this.dbContext.SaveChanges(); }
public void Create(CameraMakeType make, string model, decimal price, int quantity, int minShutterSpeed, int maxShutterSpeed, MinIsoType minIso, int maxIso, bool isFullFrame, string videoResolution, IEnumerable <LightMetering> lightMeterings, string description, string imageUrl, string userId) { var camera = new Camera { Make = make, Model = model, Price = price, Quantity = quantity, MinShutterSpeed = minShutterSpeed, MaxShutterSpeed = maxShutterSpeed, MinISO = minIso, MaxISO = maxIso, IsFullFrame = isFullFrame, VideoResolution = videoResolution, LightMetering = (LightMetering)lightMeterings.Cast <int>().Sum(), Description = description, ImageUrl = imageUrl, UserId = userId }; this.db.Add(camera); this.db.SaveChanges(); }
public void Edit(int id, CameraMakeType make, string model, decimal price, int quantity, int minShutterSpeed, int maxShutterSpeed, MinIsoType minISO, int maxISO, bool isFullFrame, string videoResolution, LightMetering lightMetering, string description, string imageUrl) { var camera = this.db.Cameras.Find(id); if (camera == null) { return; } camera.Make = make; camera.Model = model; camera.Price = price; camera.Quantity = quantity; camera.MinShutterSpeed = minShutterSpeed; camera.MaxShutterSpeed = maxShutterSpeed; camera.MinISO = minISO; camera.MaxISO = maxISO; camera.IsFullFrame = isFullFrame; camera.VideoResolution = videoResolution; camera.LightMetering = lightMetering; camera.Description = description; camera.ImageUrl = imageUrl; this.db.SaveChanges(); }