예제 #1
0
 //register client
 public HttpResponseMessage RegistrationPost(Clients NewClient)
 {
     using (ZeroTelcomeEntities3 db = new ZeroTelcomeEntities3()) {
         if (db.Clients.Any(x => x.Id == NewClient.Id))
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Id is already exist"));
         }
         else
         {
             db.Clients.Add(NewClient);
             db.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.OK, NewClient.FirstName + "Has been creatd"));
         }
     }
 }
예제 #2
0
 // delete client
 public HttpResponseMessage DeleteClinet(string id)
 {
     using (ZeroTelcomeEntities3 db = new ZeroTelcomeEntities3())
     {
         Clients client = db.Clients.FirstOrDefault(c => c.Id == id);
         if (client != null)
         {
             db.Clients.Remove(client);
             db.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.OK, "The client has been removed"));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Not found "));
         }
     }
 }
예제 #3
0
        //customer adding line
        public HttpResponseMessage PutPackage(int Packageid, [FromBody] Clients UpdateClient)
        {
            using (ZeroTelcomeEntities3 db = new ZeroTelcomeEntities3())
            {
                if (UpdateClient.Isbuisness == false && UpdateClient.Lines == null)
                {
                    UpdateClient.Lines = db.Packages.FirstOrDefault(p => p.PackageId == Packageid).PackageId;
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "Your current line is" + UpdateClient.Lines));
                }

                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "You cant add package"));
                }
            }
        }