Ejemplo n.º 1
0
        // PUT api/<controller>/5
        public object Put(int pid, Mystock u)
        {
            try
            {
                if (pid == u.PId)
                {
                    mst.Entry(u).State = System.Data.Entity.EntityState.Modified;
                    mst.SaveChanges();
                    return(new Response
                    {
                        Status = "Updated",
                    });
                }
                else
                {
                    return(new Response
                    {
                        Status = "opps",
                    });
                }
            }
            catch (Exception e)
            {
                Console.Write("error");
            }

            return(new Response
            {
                Status = "Error",
            });
        }
Ejemplo n.º 2
0
 // POST api/<controller>
 public object Post(Mystock u)
 {
     try
     {
         mst.Mystocks.Add(u);
         mst.SaveChanges();
         return(new Response
         {
             Status = "added",
         });
     }
     catch (Exception ex)
     {
         Console.Write(ex.Message);
         return(new Response
         {
             Status = "Error",
         });
     }
 }
Ejemplo n.º 3
0
        public Response Delete(int PId)
        {
            Mystock u = mst.Mystocks.Find(PId);

            if (u != null)
            {
                mst.Mystocks.Remove(u);
                mst.SaveChanges();
                return(new Response
                {
                    Status = "deleted",
                });
            }
            else
            {
                return(new Response
                {
                    Status = "Not deleted",
                });
            }
        }