Ejemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody]  Engine.Contracts.PadContract pad)
        {
            var existingpad = this.context.Pads.Where(p => p.Id == pad.Id).FirstOrDefault();

            if (existingpad == null)
            {
                return(NotFound());
            }
            var model = pad.ToModel();

            this.context.Pads.Update(model);
            this.context.SaveChanges();
            return(await Task.FromResult(Ok(model.ToContract())));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([FromBody] Engine.Contracts.PadContract pad, [FromQuery] Guid user)
        {
            var model = pad.ToModel();

            model.UserId = user;
            this.context.Add(model);

            this.context.SaveChanges();
            this.context.Add(new PadManager.Core.Models.AccountPad()
            {
                UserId = user,
                PadId  = model.Identifier
            });
            this.context.SaveChanges();

            return(await Task.FromResult(Ok(model.ToContract())));
        }