コード例 #1
0
        public IHttpActionResult PutNGO(int id, NGO nGO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != nGO.NGO_Id)
            {
                return(BadRequest());
            }

            db.Entry(nGO).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NGOExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <IActionResult> PutNGO(Guid id, NGO nGO)
        {
            if (id != nGO.ID)
            {
                return(BadRequest());
            }

            _context.Entry(nGO).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NGOExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <ActionResult <NGOModel> > GetByID(Guid id)
        {
            NGO ngo = await applicationDbContext.NGOs.FindAsync(id);

            if (ngo == null)
            {
                return(NotFound());
            }

            NGOModel ngoModel = new NGOModel
            {
                Id                      = ngo.ID,
                Name                    = ngo.Name,
                Status                  = ngo.NGOStatus,
                CreatedBy               = applicationDbContext.Users.Find(ngo.CreatedByID.ToString()).Email,
                HeadquartersAddress     = ngo.HeadquartersAddress,
                HeadquartersPhoneNumber = ngo.HeadquartersPhoneNumber,
                HeadquartersEmail       = ngo.HeadquartersEmail,
                IdentificationNumber    = ngo.IdentificationNumber,
                Website                 = ngo.Website,
                CategoryName            = applicationDbContext.Categories.FirstOrDefault(c => c.ID == ngo.CategoryID)?.Name,
                ServiceName             = applicationDbContext.Services.FirstOrDefault(c => c.ID == ngo.ServiceID)?.Name
            };

            return(ngoModel);
        }
コード例 #4
0
        public async Task <ActionResult <NGO> > PostNGO(NGO nGO)
        {
            _context.NGOs.Add(nGO);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNGO", new { id = nGO.ID }, nGO));
        }
コード例 #5
0
        public ActionResult RaiseDonation()
        {
            string       username     = (string)Session["UserId"];
            NGO          ngo          = db.NGOes.FirstOrDefault(n => n.Username == username);
            Verification verification = db.Verifications.Find(ngo.NId);

            if (verification != null)
            {
                if (verification.status.Equals("pending"))
                {
                    return(RedirectToAction("Pending"));
                }
                if (verification.status.Equals("Rejected"))
                {
                    return(RedirectToAction("Reject"));
                }
                if (verification.status.Equals("Verified"))
                {
                    return(RedirectToAction("Donation"));
                }
            }
            else
            {
                return(RedirectToAction("verification", "NGO"));
            }
            return(View());
        }
コード例 #6
0
        public IActionResult AddNGO(NgoViewModel viewModel)
        {
            var ngo = new NGO
            {
                NgoName       = viewModel.NgoName,
                NgoAddress    = viewModel.NgoAddress,
                NGOId         = 0,
                work          = viewModel.work,
                team          = viewModel.team,
                facebookLink  = viewModel.facebookLink,
                instagramLink = viewModel.instagramLink,
                phoneNumber   = viewModel.phoneNumber,
                websiteLink   = viewModel.websiteLink
            };
            var uploadedImage = viewModel.imageUpload;

            if (uploadedImage.ContentType.ToLower().StartsWith("Image/"))
            {
                //    var root = he.WebRootPath;
                //    root = root + "\\SubmittedInitiativeImg";
                ////same file name problems
                //var filename = Path.Combine(he.WebRootPath, Path.GetFileName(uploadedImage.FileName));
                var name     = Guid.NewGuid() + Path.GetFileName(uploadedImage.FileName);
                var filename = Path.Combine(he.WebRootPath, name);

                uploadedImage.CopyTo(new FileStream(filename, FileMode.Create));
                ngo.filepath = "/" + name;
            }

            ngo.categoryId = viewModel.categoryId;
            ngo.Category   = viewModel.Category;
            _dbContext.Add(ngo);
            _dbContext.SaveChanges();
            return(Redirect(viewModel.returnUrl ?? "/Admin/NGOS"));
        }
コード例 #7
0
        public IHttpActionResult PostNGO(NGO nGO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NGOes.Add(nGO);
            db.SaveChanges();

            return(CreatedAtRoute("route1", new { id = nGO.NGO_Id }, nGO));
        }
コード例 #8
0
        public async Task <ActionResult <NGOModel> > VerifyByID(NGOModel ngoModel)
        {
            NGO ngo = await applicationDbContext.NGOs.FindAsync(ngoModel.Id);

            if (ngo != null)
            {
                ngo.NGOStatus   = NGOStatus.Verified;
                ngoModel.Status = ngo.NGOStatus;
                await applicationDbContext.SaveChangesAsync();
            }

            return(ngoModel);
        }
コード例 #9
0
        public IActionResult RegisterAsNGO()
        {
            Identity identity = ControllerContext.GetIdentity();

            Volunteer   volunteer   = applicationDbContext.Volunteers.FirstOrDefault(x => x.ID == identity.ID && x.VolunteerStatus == VolunteerStatus.PendingVerification);
            Beneficiary beneficiary = applicationDbContext.Beneficiaries.FirstOrDefault(x => x.ID == identity.ID && x.Status == BeneficiaryStatus.PendingVerification);

            ViewBag.OtherPendingApplication = volunteer != null || beneficiary != null;

            NGO ngo = applicationDbContext.NGOs.FirstOrDefault(x => x.NGOStatus == NGOStatus.PendingVerification && x.CreatedByID == identity.ID);

            return(View(ngo));
        }
コード例 #10
0
        public IHttpActionResult GetNGO(int id)
        {
            NGO ngo = db.NGOes.Find(id);

            if (ngo == null)
            {
                return(NotFound());
            }
            DTO_NGO dngo = new DTO_NGO();

            ngo.ConvertToDTO(dngo);
            return(Ok(dngo));
        }
コード例 #11
0
 public ActionResult Details()
 {
     if (Session["UserId"] != null)
     {
         string username = (string)Session["UserId"];
         NGO    ngo      = db.NGOes.FirstOrDefault(n => n.Username == username);
         return(View(ngo));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
コード例 #12
0
        public ActionResult NGODetail()
        {
            string username = (string)Session["UserId"];
            List <Verification> verified = db.Verifications.Where(n => n.status == "Verified").ToList();
            NGO        ngo  = new NGO();
            List <NGO> ngos = new List <NGO>();

            foreach (Verification verify in verified)
            {
                ngo = db.NGOes.FirstOrDefault(n => n.NId == verify.Id);
                ngos.Add(ngo);
            }
            return(View(ngos));
        }
コード例 #13
0
        public IHttpActionResult DeleteNGO(int id)
        {
            NGO nGO = db.NGOes.Find(id);

            if (nGO == null)
            {
                return(NotFound());
            }

            db.NGOes.Remove(nGO);
            db.SaveChanges();

            return(Ok(nGO));
        }
コード例 #14
0
        public async Task <IActionResult> RaisedEvents(int id)
        {
            //List<NGO> ngoList = new List<NGO>();
            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.GetAsync("http://localhost:14780/api/NGO/GetbyId/" + id))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    //ViewBag.Result = "Success";
                    NGO ngoList = JsonConvert.DeserializeObject <NGO>(apiResponse);
                }
            }
            return(View());
        }
コード例 #15
0
 public ActionResult Donation()
 {
     if (Session["UserId"] != null)
     {
         string        username = (string)Session["UserId"];
         NGO           ngo      = db.NGOes.FirstOrDefault(n => n.Username == username);
         Raisedonation raise    = new Raisedonation();
         raise.NId = ngo.NId;
         return(View(raise));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
コード例 #16
0
 public ActionResult Register(NGO ngo)
 {
     if (ModelState.IsValid)
     {
         LoginDetail login = new LoginDetail();
         login.Username = ngo.Username;
         login.Password = ngo.Password;
         login.LoginAs  = "NGO";
         db.LoginDetails.Add(login);
         db.NGOes.Add(ngo);
         db.SaveChanges();
         return(RedirectToAction("Login", "Login"));
     }
     return(View());
 }
コード例 #17
0
        public ActionResult Register()
        {
            NGO ng      = new NGO();
            NGO lastNgo = db.NGOes.OrderByDescending(n => n.NId).FirstOrDefault();

            if (lastNgo == null)
            {
                ng.NId = "NG1";
            }
            else
            {
                ng.NId = "NG" + (Convert.ToInt32(lastNgo.NId.Substring(2, lastNgo.NId.Length - 2)) + 1).ToString();
            }
            return(View(ng));
        }
コード例 #18
0
        public async Task <IActionResult> DeleteNgo(int id)
        {
            NGO ngo = new NGO();

            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.GetAsync("http://localhost:14780/api/NGO/GetbyId/" + id))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    ngo = JsonConvert.DeserializeObject <NGO>(apiResponse);
                }
            }
            return(View(ngo));
        }
コード例 #19
0
        // GET: NGOs/Delete/5
        public async Task <IActionResult> Delete(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            NGO ngo = await applicationDbContext.NGOs.FirstOrDefaultAsync(m => m.ID == id);

            if (ngo == null)
            {
                return(NotFound());
            }

            return(View(ngo));
        }
コード例 #20
0
        public void mail(string Username, string trid)
        {
            Donation dn      = db.Donations.Find(trid);
            Donar    donar   = db.Donars.FirstOrDefault(d => d.DId == dn.DId);
            NGO      ngo     = db.NGOes.FirstOrDefault(n => n.NId == dn.NgId);
            string   subject = "Donation Receipt";
            string   body    = "Hello " + donar.DName.ToUpperInvariant() + ",\nThank you for making donation for NGO.Here is the receipt of Donation you have made for your future references.\n\nAmount          : Rs" + dn.Amount + "\n\n" +
                               "Donar ID        : " + donar.DId + "\n\n" +
                               "NGO ID          : " + ngo.NId + "\n\n" +
                               "NGO Name        : " + ngo.NgName + "\n\n" +
                               "Transaction Id  : " + trid + "\n\n" +
                               "Transaction Date: " + dn.TransactionDate + "\n\n\n\n" +
                               "Thank You";

            SendEmail(Username, subject, body);
        }
コード例 #21
0
        public void mail(Verification verification)
        {
            NGO    ngo     = db.NGOes.Find(verification.Id);
            string subject = "Account Verification";
            string vbody   = "Hello, " + ngo.NgName + " your request for account verification to raise funds is accepted. You can now raise donations from donars from the website.";
            string rbody   = "Hello, " + ngo.NgName + " your request for account verification to raise funds is rejected as documents uploaded by you were not clear. So,please resubmit your application with correct and valid documents. Thank You.";

            if (verification.status.Equals("Verified"))
            {
                SendEmail(ngo.Username, subject, vbody);
            }
            if (verification.status.Equals("Rejected"))
            {
                SendEmail(ngo.Username, subject, rbody);
            }
        }
コード例 #22
0
        public ActionResult verify()
        {
            string       username     = (string)Session["UserId"];
            NGO          ngo          = db.NGOes.FirstOrDefault(n => n.Username == username);
            Verification verification = db.Verifications.Find(ngo.NId);

            if (verification == null)
            {
                return(RedirectToAction("verification"));
            }
            else
            {
                db.Verifications.Remove(verification);
                db.SaveChanges();
                return(RedirectToAction("verification"));
            }
        }
コード例 #23
0
        public ActionResult Login(LoginDetail loginDetails)
        {
            if (ModelState.IsValid)
            {
                LoginDetail user = new LoginDetail();
                user = db.LoginDetails.FirstOrDefault(u => u.Username == loginDetails.Username);
                if (user != null)
                {
                    if (user.Username == loginDetails.Username && user.Password == loginDetails.Password)
                    {
                        Session["UserId"] = user.Username;

                        if (user.LoginAs.Equals("Donar"))
                        {
                            Donar donar = db.Donars.FirstOrDefault(d => d.Username == user.Username);
                            TempData["Dname"] = donar.DName;
                            return(RedirectToAction("Index", "Donar"));
                        }
                        if (user.LoginAs.Equals("NGO"))
                        {
                            NGO ngo = db.NGOes.FirstOrDefault(n => n.Username == user.Username);
                            TempData["Ngname"] = ngo.NgName;
                            return(RedirectToAction("start", "NGO"));
                        }
                        if (user.LoginAs.Equals("Admin"))
                        {
                            return(RedirectToAction("Index", "Admin"));
                        }
                    }
                    else
                    {
                        ViewBag.Message = "Invalid Password";
                    }
                    return(View());
                }
                else
                {
                    ViewBag.Message = "User does not exist";
                    return(View());
                }
            }
            return(View());
        }
コード例 #24
0
        public async Task <IActionResult> RegisterAsNGO([Bind(nameof(NGO.Name))] NGO ngo)
        {
            if (ModelState.IsValid)
            {
                Identity identity = ControllerContext.GetIdentity();

                ngo.ID          = Guid.NewGuid();
                ngo.CreatedByID = identity.ID;
                ngo.NGOStatus   = NGOStatus.PendingVerification;

                applicationDbContext.Add(ngo);

                await applicationDbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(ngo));
        }
コード例 #25
0
 public ActionResult Donation(Raisedonation raisedonation)
 {
     if (ModelState.IsValid)
     {
         string        username = (string)Session["UserId"];
         NGO           ngo      = db.NGOes.FirstOrDefault(n => n.Username == username);
         Raisedonation donation = db.Raisedonations.FirstOrDefault(d => d.NId == ngo.NId);
         if (donation == null)
         {
             db.Raisedonations.Add(raisedonation);
             db.SaveChanges();
             return(RedirectToAction("success"));
         }
         else
         {
             return(RedirectToAction("already"));
         }
     }
     return(View());
 }
コード例 #26
0
        //public IActionResult Index()
        //{
        //    return View();
        //}
        public async Task <IActionResult> Index(string name)
        {
            List <NGO> ngoList = new List <NGO>();

            using (var httpClient = new HttpClient())
            {
                //
                using (var response = await httpClient.GetAsync("http://localhost:14780/api/NGO"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    ngoList = JsonConvert.DeserializeObject <List <NGO> >(apiResponse);
                }
            }
            NGO ngo = ngoList.FirstOrDefault(d => d.NgoUserName == name);

            TempData["ngoname"] = ngo.NgoName;
            TempData["ngoid"]   = ngo.NgoId;
            return(View());
        }
コード例 #27
0
        public async Task <IActionResult> Register(NGO ngo)
        {
            NGO nGO = new NGO();

            using (var httpClient = new HttpClient())
            {
                //int id = verify.VerificationId;
                StringContent content = new StringContent(JsonConvert.SerializeObject(ngo), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PostAsync("http://localhost:14780/api/NGO/NgoRegister", content))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    //ViewBag.Result = "Success";
                    nGO            = JsonConvert.DeserializeObject <NGO>(apiResponse);
                    ViewBag.Result = "Successfully Registered, Please Login.....THANKYOU";
                }
            }
            return(View());
        }
コード例 #28
0
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            NGO ngo = await applicationDbContext.NGOs.FindAsync(id);

            if (ngo == null)
            {
                return(NotFound());
            }

            ngo.CreatedByName    = applicationDbContext.Users.Find(ngo.CreatedByID.ToString()).Email;
            ViewBag.CategoryName = applicationDbContext.Categories.FirstOrDefault(c => c.ID == ngo.CategoryID)?.Name;
            ViewBag.ServiceName  = applicationDbContext.Services.FirstOrDefault(s => s.ID == ngo.ServiceID)?.Name;

            return(View(ngo));
        }
コード例 #29
0
        public IActionResult RegisterAsVolunteer()
        {
            Identity identity = ControllerContext.GetIdentity();

            NGO         ngo         = applicationDbContext.NGOs.FirstOrDefault(x => x.CreatedByID == identity.ID && x.NGOStatus == NGOStatus.PendingVerification);
            Beneficiary beneficiary = applicationDbContext.Beneficiaries.FirstOrDefault(x => x.ID == identity.ID && x.Status == BeneficiaryStatus.PendingVerification);

            ViewBag.OtherPendingApplication = ngo != null || ngo != null;

            if (!ViewBag.OtherPendingApplication)
            {
                Volunteer volunteer = applicationDbContext.Volunteers.FirstOrDefault(x => x.VolunteerStatus == VolunteerStatus.PendingVerification && x.ID == identity.ID);

                volunteer.Name = applicationDbContext.Users.Find(identity.ID.ToString()).Email;

                return(View(volunteer));
            }

            return(View());
        }
コード例 #30
0
        public async Task <IActionResult> DeleteNgo(int id, NGO n)
        {
            NGO ngo = new NGO();

            using (var httpClient = new HttpClient())
            {
                // int id = verify.VerificationId;
                StringContent content = new StringContent(JsonConvert.SerializeObject(ngo), Encoding.UTF8, "application/json");

                using (var response = await httpClient.DeleteAsync("http://localhost:14780/api/NGO/DeletebyId/" + id))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    //ViewBag.Result = "Success";
                    ngo = JsonConvert.DeserializeObject <NGO>(apiResponse);
                }
            }

            return(RedirectToAction("Index"));
        }
コード例 #31
0
ファイル: AddNGO.aspx.cs プロジェクト: ziad007/URI2
    protected void Button1_Click(object sender, EventArgs e)
    {
        NGO objNGO = new NGO();
            // objNGO.NGOName = txtbrandname.Text;
               /*    objNGO.NGOCategoryID= ddlcategory.SelectedValue;
             objNGO.Website = txtwebsite.Text;
             objNGO.NGODescription = txtdiscption.InnerText;

             objNGO.FacebookPage= facebook.Text;
             objNGO.TwitterPage = Twitter.Text;
             objNGO.YoutubeChannel = Youtube.Text;
             objNGO.GooglePlus = GooglePlus.Text;
             objNGO.Blog = Blog.Text;
             objNGO.Flicker = Flickr.Text;
             objNGO.FourSquareAccount = FoursquareAccount.Text;
             //objNGO.lindkin = LinkedIn.Text;

            string str= objNGO.CreateBransh(objNGO);
         */
    }
コード例 #32
0
ファイル: NGO.cs プロジェクト: YannickLange/ForestGame
    void Awake()
    {
        _thisTransform = transform;
        _rb = GetComponent<Rigidbody>();
        isNGOWaiting = false;

        if (instance == null)
            instance = this;
    }