public string InstituteInsert(InstitutionMaster data, FormCollection fc, HttpPostedFileBase file)
        {
            var allowedExtensions = new[] {
                ".Jpg", ".png", ".jpg", "jpeg"
            };

            var fileName = Path.GetFileName(file.FileName);  //getting only file name(ex-ganesh.jpg)
            var ext      = Path.GetExtension(file.FileName); //getting the extension(ex-.jpg)

            if (allowedExtensions.Contains(ext))             //check what type of extension
            {
                //string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                // store the file inside ~/project folder(Img)
                path = Path.Combine(Server.MapPath("~/Images/") + file.FileName);
                file.SaveAs(path);
            }

            System.Data.Entity.Core.Objects.ObjectParameter msg = new System.Data.Entity.Core.Objects.ObjectParameter("msg", typeof(string));
            if (ModelState.IsValid)
            {
                entity.InstitutionMaster_CURD(data.InstitutionName, data.Phone, data.Email, data.Website, data.Area, data.Address1, data.Address2, data.Address3, data.Building, data.Room, data.TRN, path, data.ShortName, "Insert", msg);

                return("0");
            }

            return("-1");
        }
Exemple #2
0
        public IActionResult Put([FromBody] InstitutionMaster req)
        {
            bool result = _repo.Update(req);

            if (result)
            {
                return(Ok("Success"));
            }

            return(Ok("Fail"));
        }