Example #1
0
        public async Task<IHttpActionResult> AddInstution(Institution foo)
        {

            //var contentType = Request.Content.Headers.ContentType.MediaType;
            //var pp = System.Web.HttpContext.Current.Request["RegisterBindingModel"];

            // Bank foo = Newtonsoft.Json.JsonConvert.DeserializeObject<Bank>(pp) as Bank;

            //  JsonSerializer serializer = JsonSerializer.Create(Configuration.Formatters.JsonFormatter.SerializerSettings);

            //  var requestParams = Request.Content.ReadAsStringAsync().Result;


            var httpRequest = HttpContext.Current.Request;





            try
            {
                var _db = new ApplicationDbContext();
                string currentUserId = User.Identity.GetUserId();
                Institution aaa = new Institution();
                aaa.Institution_Code = foo.Institution_Code;
                aaa.Institution_Name = foo.Institution_Name;
                aaa.InstitutionType_Code = foo.InstitutionType_Code;

                _db.Institutions.Add(aaa);

                var kk = _db.SaveChanges();
                //   _db.SaveChanges();
                return Ok();

            }
            catch (Exception ee)
            {
                return BadRequest(); ;
            }




        }
Example #2
0
        public List<Institution> GetClient()
        {
            var _db = new ApplicationDbContext();


            var vv = (from c in _db.Institution_Type

                      join o in _db.Institutions on new { a = c.InstitutionType_Code } equals new { a = o.InstitutionType_Code }
                      // where ((o.parent_id == User.Identity.Name))

                      //    where ((c.DateCreated.Date == start_date) && (c.DateCreated.Date <= end_date))
                      //      where (c.DateCreated.Date >= start_date.Date && c.DateCreated.Date <= end_date.Date)



                      select new { c.InstitutionType_Name, o.Institution_Code, o.Institution_Name }).ToList();

            List<Institution> kk = new List<Institution>();
            foreach (var dd in vv)
            {
                Institution xx = new Institution();
                xx.Institution_Code = dd.Institution_Code;
                xx.Institution_Name = dd.Institution_Name;
                xx.InstitutionType_Code = dd.InstitutionType_Name;
              
                kk.Add(xx);

            }


          //  List<Clients> currentUser = _db.Clients.ToList();





            return kk;
        }
Example #3
0
        public async Task<IHttpActionResult> AddClients(Institution foo2)
        {
            var httpRequest = HttpContext.Current.Request;


            //var pp = System.Web.HttpContext.Current.Request["CreateRoleBindingModel"];

            //Clients foo = Newtonsoft.Json.JsonConvert.DeserializeObject<Clients>(pp) as Clients;
            //if (httpRequest.Files.Count > 0)
            //{
            //    foreach (string file in httpRequest.Files)
            //    {
            //        var files = new List<string>();
            //        if (file == "FileUpload")
            //        {

            //            var postedFile = httpRequest.Files[file];
            //            var vfile = postedFile.FileName.Replace("\"", string.Empty).Replace("'", string.Empty);

            //            vfile = Stp(vfile);
            //            string FileName = HttpContext.Current.Server.MapPath("~/Img/" + vfile);
            //            //   dd.cac_file = "/images/" + vfile;

            //            foo.Image_url = "Img/" + vfile;

            //            postedFile.SaveAs(FileName);



            //        }
            //    }



            //}

            var _db = new ApplicationDbContext();

            _db.Institutions.Add(foo2);
            _db.SaveChanges();
            return Ok();
        }
Example #4
0
        public List<Institution> GetInstitution2([FromUri] String property1)
        {
            var _db = new ApplicationDbContext();

            var vv = (from c in _db.Institution_Type

                      join o in _db.Institutions on new { a = c.InstitutionType_Code } equals new { a = o.InstitutionType_Code }

                      where c.InstitutionType_Code == property1


                      select new { c.InstitutionType_Name, o.Institution_Code, o.Institution_Name }).ToList();

            List<Institution> kk = new List<Institution>();
            foreach (var dd in vv)
            {
                Institution xx = new Institution();
                xx.Institution_Code = dd.Institution_Code;
                xx.Institution_Name = dd.Institution_Name;
                xx.InstitutionType_Code = dd.InstitutionType_Name;

                kk.Add(xx);

            }


           // List<Institution_Type> currentUser = _db.Institution_Type.ToList();





            return kk;
        }