Beispiel #1
0
        public async Task <HttpResponseMessage> PostRegisterAsync([FromBody] registered register_obj)
        {
            try
            {
                using (hcp_apiEntities6 entities = new hcp_apiEntities6())
                {
                    entities.registereds.Add(register_obj);

                    if (await GetValidateAsync(register_obj.national_id, Convert.ToDateTime(register_obj.dob), register_obj.surname) == "1")
                    {
                        entities.SaveChanges();

                        var message = Request.CreateResponse(HttpStatusCode.Created, register_obj);
                        message.Headers.Location = new Uri(Request.RequestUri + register_obj.national_id.ToString());
                        return(message);
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong user"));
                    }
                }
            }
            catch (System.Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
                // throw;
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            registered registered = db.registered.Find(id);

            db.registered.Remove(registered);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,account,password,img,name,email,phone,address,Authority")] registered registered)
 {
     if (ModelState.IsValid)
     {
         db.Entry(registered).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(registered));
 }
        public ActionResult Create([Bind(Include = "id,account,password,img,name,email,phone,address,Authority")] registered registered)
        {
            if (ModelState.IsValid)
            {
                db.registered.Add(registered);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(registered));
        }
        // GET: registereds/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            registered registered = db.registered.Find(id);

            if (registered == null)
            {
                return(HttpNotFound());
            }
            return(View(registered));
        }
Beispiel #6
0
 public IHttpActionResult PostRegister_ChurchAsync([FromBody] registered regi_obj)
 {
     try
     {
         using (hcp_apiEntities6 entities = new hcp_apiEntities6())
         {
             using (SqlConnection sqlCon = new SqlConnection(obj.locate1))
             {
                 sqlCon.Open();
                 string     query  = "UPDATE registered set church = '" + regi_obj.church + "' where phone_number = '" + regi_obj.phone_number.Trim() + "'";
                 SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
                 sqlCmd.ExecuteNonQuery();
             }
             var message = Request.CreateResponse(HttpStatusCode.Created, regi_obj);
             message.Headers.Location = new Uri(Request.RequestUri + regi_obj.church.ToString());
             return(Ok("Registered"));
         }
     }
     catch (System.Exception ex)
     {
         return(Ok(ex.ToString()));
         // throw;
     }
 }