Ejemplo n.º 1
0
        public async override Task <ProbaActionReply> EditProba(ProbaMessage request, ServerCallContext context)
        {
            var reply = new ProbaActionReply();

            try
            {
                var existing = await db.Probas.FindAsync(request.Greeting);

                if (existing != null)
                {
                    existing.Date  = request.Date;
                    existing.Count = request.Count;
                    existing.Added = request.Added;
                    db.Probas.Update(existing);
                    await db.SaveChangesAsync();

                    reply.Message = "Successfully edited";
                    reply.Success = true;
                }
                else
                {
                    reply.Message = "Unable to find the item for editing";
                    reply.Success = false;
                }
            }
            catch (Exception ex)
            {
                WriteException(reply, ex);
            }

            return(reply);
        }
Ejemplo n.º 2
0
        public async override Task <ProbaActionReply> AddProba(ProbaMessage request, ServerCallContext context)
        {
            var reply = new ProbaActionReply();

            try
            {
                db.Probas.Add(request);
                await db.SaveChangesAsync();

                reply.Message = "Successfully added";
            }
            catch (Exception ex)
            {
                WriteException(reply, ex);
            }

            return(reply);
        }
Ejemplo n.º 3
0
        public async override Task <ProbaActionReply> DeleteProba(ProbaMessage request, ServerCallContext context)
        {
            var reply = new ProbaActionReply();

            try
            {
                var r = db.Probas.Remove(request);

                await db.SaveChangesAsync();

                reply.Message = "Successfully deleted";
                reply.Success = true;
            }
            catch (Exception ex)
            {
                WriteException(reply, ex);
            }

            return(reply);
        }