Esempio n. 1
0
 public static GateModel GetModelFromContract(GateContractsModel model)
 {
     return(model == null ? null : new GateModel
     {
         Id = model.Id,
         Gate = model.Gate,
         Status = model.Status
     });
 }
        public bool Save(GateContractsModel gate)
        {
            if (gate == null)
            {
                throw new ArgumentNullException(nameof(gate));
            }

            using (_context)
            {
                this._gate = this._context.Gate.FirstOrDefault(x => x.Id == gate.Id);
                this._gate = ModelConverterHelper.GetModelFromContract(gate);
                this._context.SaveChanges();
            }

            return(true);
        }
        public bool Add(GateContractsModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            using (_context)
            {
                this._gate = ModelConverterHelper.GetModelFromContract(model);
                this._context.Gate.Add(this._gate);
                this._context.SaveChanges();
            }

            return(true);
        }