Exemplo n.º 1
0
        //public IHttpActionResult Post(int id)
        //{
        //    try
        //    {
        //        docupload d = new docupload();
        //        var file = Request.Form.Files[0];
        //        var folderName = Path.Combine("Resources", "Images");
        //        var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);
        //        //string realpath = Server.MapPath("/images") + "//" + file.FileName;
        //        //file.SaveAs(realpath);
        //        //c.productData.path = file.FileName;

        //        if (file.Length > 0)
        //        {
        //            var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
        //            var fullPath = Path.Combine(pathToSave, fileName);
        //            var dbPath = Path.Combine(folderName, fileName);
        //            using (var stream = new FileStream(fullPath, FileMode.Create))
        //            {
        //                file.CopyTo(stream);
        //            }
        //            d.DocName = fileName;
        //            d.Path = dbPath;
        //            //d.AccepterId = Convert.ToInt32(Message);
        //            context.Add(d);
        //            context.SaveChanges();

        //            return Ok();
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return StatusCode(500, $"Internal server error: {ex}");
        //    }
        //}


        public IHttpActionResult Put(int id, [FromBody] accepter s)
        {
            accepter a = context.accepters.Single(accepter => accepter.accepter_id == id);

            a.accepter_name  = s.accepter_name;
            a.father_name    = s.father_name;
            a.email          = s.email;
            a.password       = s.password;
            a.contact_no     = s.contact_no;
            a.CNIC           = s.CNIC;
            a.DOB            = s.DOB;
            a.country        = s.country;
            a.city           = s.city;
            a.state          = s.state;
            a.address        = s.address;
            a.zip_code       = s.zip_code;
            a.gender         = s.gender;
            a.occupation     = s.occupation;
            a.family_members = s.family_members;
            a.marital_status = s.marital_status;
            a.salary         = s.salary;


            //context.Update(s);
            context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 2
0
        public IHttpActionResult post([FromBody] login adata)
        {
            login p = adata;

            context.logins.Add(p);
            context.SaveChanges();

            if (p.type == "accepter")
            {
                var res = from m in context.accepters
                          where m.email == p.email
                          select m;
                foreach (var m in res)
                {
                    if (m.email == p.email && m.password == p.password)
                    {
                        Message = m.accepter_id;
                    }
                }
                accepter result = context.accepters.Single(accepter => accepter.email == p.email);
            }
            else if (p.type == "donor")
            {
                var res = from m in context.donors
                          where m.email == p.email
                          select m;
                foreach (var m in res)
                {
                    if (m.email == p.email && m.password == p.password)
                    {
                        Message = m.donor_id;
                    }
                }
                donor result = context.donors.Single(donor => donor.email == p.email);
            }
            else if (p.type == "admin")
            {
                var res = from m in context.admins
                          where m.email == p.email
                          select m;
                foreach (var m in res)
                {
                    if (m.email == p.email && m.password == p.password)
                    {
                        Message = m.admin_id;
                    }
                }
                admin result = context.admins.Single(admin => admin.email == p.email);
            }

            return(Ok(Message));
        }
Exemplo n.º 3
0
        public IHttpActionResult post([FromBody] accepter adata)
        {
            accepter p = adata;

            context.accepters.Add(p);

            notification n = new notification();

            n.accepter_id = p.accepter_id;
            n.title       = "Need Verification for Accepter";
            n.status      = "0";
            context.notifications.Add(n);

            context.SaveChanges();

            accepter a = context.accepters.Single(accepter => accepter.email == adata.email);

            n.accepter_id = a.accepter_id;
            context.SaveChanges();


            //EmailClass ec = new EmailClass();
            //ec.subject = "Email Verification";
            //ec.body = p.code.ToString();
            //ec.to = p.email;
            //HttpClient hc = new HttpClient();
            //hc.BaseAddress = new Uri("https://localhost:44371/api/Email");

            //var consumewebapi = hc.PostAsJsonAsync<EmailClass>("email", ec);
            //consumewebapi.Wait();
            //var sendmail = consumewebapi.Result;
            //if (sendmail.IsSuccessStatusCode)
            //{

            //    Random random = new Random();
            //    p.code = random.Next(10000);
            //}


            return(Ok(new { results = adata }));
        }
Exemplo n.º 4
0
        public IHttpActionResult Get(int id)
        {
            accepter a = context.accepters.Single(accepter => accepter.accepter_id == id);

            return(Ok(new { results = a }));
        }