/// <summary>
        ///     Builds the resources for.
        /// </summary>
        /// <param name="context">Context containing information about the request.</param>
        /// <returns>
        ///     <see cref="JsonHomeDocument" /> populated according to current user's permissions.
        /// </returns>
        public JsonHomeDocument BuildResourcesFor(ITestApiContext context)
        {
            var jsonHomeDocument = new JsonHomeDocument();

            foreach (var function in Functions)
            {
                var functionName  = function.Key;
                var functionValue = function.Value;
                var webFunction   = new WebFunction(
                    functionValue.Href,
                    functionValue.Relation,
                    functionValue.Templated,
                    CreateHints(functionName, "Active", DetermineAvailableVerbs(functionName, context), null),
                    ulong.MaxValue);

                var listOfHints =
                    (IEnumerable <HttpVerb>)webFunction.Hints.FirstOrDefault(x => x.Key.Contains("allow")).Value;

                if (webFunction.RequiredPermissions > 0 && listOfHints.Any())
                {
                    jsonHomeDocument.AddFunction(functionName, webFunction);
                }
            }

            return(jsonHomeDocument);
        }
Пример #2
0
 public ObjectResult Ping()
 {
     return(WebFunction.Execute <PingResponse>(this, () =>
     {
         return new WebResult <PingResponse>(new PingResponse());
     }));
 }
        public ObjectResult ResolveOffnetServices(PartnerServPkg postData)
        {
            return(WebFunction.Execute <PartnerServPkg, PartnerServPkg>(this, postData, (osp) =>
            {
                string error;
                PartnerServPkg pkg;

                try
                {
                    var NewOsp = OffnetBiz.ResolveOffnet(osp.GetPartnerServicePackage(), out error);
                    pkg = new PartnerServPkg(NewOsp);
                }
                catch (Exception e)
                {
                    if (e.Data.Contains("Custom Msg"))
                    {
                        pkg = new PartnerServPkg {
                            ErrorString = e.Data["Custom Msg"].ToString() + e.Message, IsValid = false
                        };
                    }
                    else
                    {
                        pkg = new PartnerServPkg {
                            ErrorString = e.Message, IsValid = false
                        };
                    }
                }
                return new WebResult <PartnerServPkg>(pkg);
            }));
        }
 public ObjectResult ById(long id)
 {
     return(WebFunction.Execute <long, OffnetServiceDefinitionWeb>(this, id, (serviceId) =>
     {
         return new WebResult <OffnetServiceDefinitionWeb>(OffnetServiceDefinition.Get(serviceId).ToWeb());
     }));
 }
Пример #5
0
 public ObjectResult Number()
 {
     return(WebFunction.Execute <string, string>(this, "blah", (sv) =>
     {
         return new WebResult <string>(CacheManager.GetCacheNumber().ToString());
     }));
 }
Пример #6
0
    private void NewsInfoBind()
    {
        string ID = Request.QueryString["ID"];
        int    i  = 0;

        if (int.TryParse(ID, out i))
        {
            T_NEWSBASEEntity FM = new T_NEWSBASEEntity();
            FM.ID = int.Parse(ID);
            FM.Retrieve();
            if (FM.IsPersistent)
            {
                newstitle.InnerHtml = "<span style='color:" + FM.TITLECOLOR + ";font-size:" + FM.TITLESIZE + "px;font-family:" + FM.TITLEFONT + "'>" + FM.TITLE + "</span>";
                if (!"".Equals(FM.SUBTITLE))
                {
                    newstitle.InnerHtml = newstitle.InnerHtml + "<BR>";
                    newstitle.InnerHtml = newstitle.InnerHtml + "<span style='color:" + FM.SUBTITLECOLOR + ";font-size:" + FM.SUBTITLESIZE + "px;font-family:" + FM.SUBTITLEFONT + "'>" + FM.SUBTITLE + "</span>";
                }
                nodename.InnerText    = WebFunction.GetNodeName(FM.NODEID.ToString());
                newsinfo.InnerHtml    = "发布时间:" + FM.PUBLISHTIME.ToString() + " 文章来源:" + FM.COPYRIGHT + " 作者:" + FM.AUTHOR + " 点击数: " + FM.HITS.ToString();
                newscontent.InnerHtml = FM.CONTENT;
                FM.HITS = FM.HITS + 1;
                FM.Save();
            }
        }
    }
Пример #7
0
 public ActionResult EditUserDetails(tbl_UserDetailsss model, HttpPostedFileBase pic)
 {
     try
     {
         tbl_UserDetails abc = _user.Get(model.pkid);
         abc.FullName         = model.FullName;
         abc.ContactNumber    = model.ContactNumber;
         abc.AddressLine1     = model.AddressLine1;
         abc.RoleName         = model.RoleName;
         abc.EmailId          = model.EmailId;
         abc.LastModifiedDate = DateTime.Now;
         if (pic != null)
         {
             string path = System.Web.HttpContext.Current.Server.MapPath(model.ProdilePic);
             if (System.IO.File.Exists(path))
             {
                 System.IO.File.Delete(path);
             }
             WebFunction web = new WebFunction();
             model.ProdilePic = web.Storefile(pic, 4);
         }
         _user.Update(abc);
         return(RedirectToAction("Register", "Account"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         ViewBag.Exception = e.Message;
         return(View());
     }
 }
 public ActionResult WardMemberEntry(tbl_wardMember_Masterss model, HttpPostedFileBase Pic)
 {
     ViewBag.ward = new SelectList(_ward.GetAll(), "pkid", "ward_Name");
     try
     {
         WebFunction web = new WebFunction();
         if (model.pkid == 0)
         {
             tbl_wardMember_Master abc = new tbl_wardMember_Master();
             abc.Ward_fkid   = model.Ward_fkid;
             abc.Member_Name = model.Member_Name;
             abc.Description = model.Description;
             abc.adddate     = DateTime.Now;
             abc.status      = model.status;
             abc.Address     = model.Address;
             abc.MobileNo    = model.MobileNo;
             if (Pic != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 model.ProfilePic = web.Storefile(Pic, 5);
             }
             _wardmember.Add(abc);
         }
         else
         {
             int _id = Convert.ToInt32(model.pkid);
             tbl_wardMember_Master abc = _wardmember.Get(_id);
             abc.pkid        = model.pkid;
             abc.Ward_fkid   = model.Ward_fkid;
             abc.Member_Name = model.Member_Name;
             abc.Description = model.Description;
             abc.adddate     = DateTime.Now;
             abc.status      = model.status;
             abc.Address     = model.Address;
             abc.MobileNo    = model.MobileNo;
             if (Pic != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 model.ProfilePic = web.Storefile(Pic, 5);
             }
             _wardmember.Update(abc);
         }
         return(RedirectToAction("WardMemberEntry", "SystemMaster"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         ViewBag.Exception = e.Message;
         return(View());
     }
 }
Пример #9
0
        public ObjectResult Clear()
        {
            return(WebFunction.Execute <string, string>(this, "blah", (sv) =>
            {
                CacheManager.ClearCaches();

                return new WebResult <string>("All caches will be cleared within the next minute.");
            }));
        }
 public ObjectResult BuildChild(BuildOffnetChildServiceRequestWeb postData)
 {
     return(WebFunction.Execute <BuildOffnetChildServiceRequestWeb, OffnetHierarchyWeb>(this, postData, (req) =>
     {
         var key = new OffnetServiceKey(req.ParentService);
         var child = OffnetServiceHierarchy.BuildChild(key, req.Name);
         return new WebResult <OffnetHierarchyWeb>(child);
     }));
 }
Пример #11
0
 public ObjectResult ImpactAttributes(ImpactedServiceKeyWeb postData)
 {
     return(WebFunction.Execute <ImpactedServiceKeyWeb, ImpactAttributes>(this, postData, (k) =>
     {
         var key = new ServiceKey(k.Key);
         var impactAttributes = ServiceAttributes.GetImpactAttributes(key, k.ChangedAttributes);
         return new WebResult <ImpactAttributes>(impactAttributes);
     }));
 }
Пример #12
0
 public ObjectResult ImpactedRelatoinships(ImpactedServiceKeyWeb postData)
 {
     return(WebFunction.Execute <ImpactedServiceKeyWeb, ServiceRelationshipWeb[]>(this, postData, (si) =>
     {
         var key = new ServiceKey(si.Key);
         var rel = ServiceRelationships.GetImpactedRelationhips(key, si.ChangedAttributes).ToList().ToArray();
         return new WebResult <ServiceRelationshipWeb[]>(rel.Select(i => i.ToWeb()).ToArray());
     }));
 }
Пример #13
0
 public ObjectResult ImpactedChildren(ImpactedServiceKeyWeb postData)
 {
     return(WebFunction.Execute <ImpactedServiceKeyWeb, List <long> >(this, postData, (k) =>
     {
         var key = new ServiceKey(k.Key);
         var children = ServiceHierarchy.GetImpactedChildren(key, k.ChangedAttributes);
         return new WebResult <List <long> >(children);
     }));
 }
Пример #14
0
 public ObjectResult Config()
 {
     return(WebFunction.Execute <PingConfig>(this, () =>
     {
         var config = new PingConfig();
         config.WebHost = HttpContext.Request.Host.Value.ToString();
         return new WebResult <PingConfig>(config);
     }));
 }
 public ObjectResult Attributes(OffnetServiceAttributesKeyWeb postData)
 {
     return(WebFunction.Execute <OffnetServiceAttributesKeyWeb, OffnetAttributeSourcesInfoWeb>(this, postData, (sa) =>
     {
         OffnetAttributeSourcesInfoWeb info;
         var sKey = new OffnetServiceKey(sa);
         info = OffnetServiceAttributes.GetAttributes(sKey, sa.PopulateLists);
         return new WebResult <OffnetAttributeSourcesInfoWeb>(info);
     }));
 }
        public ObjectResult Children(OffnetServiceKeyWeb postData)
        {
            return(WebFunction.Execute <OffnetServiceKeyWeb, List <OffnetServiceChildWeb> >(this, postData, (sv) =>
            {
                var key = new OffnetServiceKey(sv);
                var children = OffnetServiceHierarchy.Get(key);

                return new WebResult <List <OffnetServiceChildWeb> >(children.Select(c => c.ToWeb()).ToList());
            }));
        }
Пример #17
0
 public ActionResult NewsAndUpdated(tbl_NewsAndUpdatedss model, HttpPostedFileBase files)
 {
     try
     {
         if (model.pkid == 0)
         {
             tbl_NewsAndUpdated abc = new tbl_NewsAndUpdated();
             abc.Title        = model.Title;
             abc.Description  = model.Description;
             abc.status       = model.status;
             abc.ProfilePic   = model.ProfilePic;
             abc.Addate       = DateTime.Now;
             abc.lastModified = DateTime.Now;
             if (files != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 WebFunction web = new WebFunction();
                 abc.ProfilePic = web.Storefile(files, 6);
             }
             _news.Add(abc);
         }
         else
         {
             int _id = Convert.ToInt32(model.pkid);
             tbl_NewsAndUpdated abc = _news.Get(_id);
             abc.Title        = model.Title;
             abc.status       = model.status;
             abc.Description  = model.Description;
             abc.ProfilePic   = model.ProfilePic;
             abc.lastModified = DateTime.Now;
             if (files != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 WebFunction web = new WebFunction();
                 abc.ProfilePic = web.Storefile(files, 6);
             }
             _news.Update(abc);
         }
         return(RedirectToAction("NewsAndUpdated", "Administration"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         ViewBag.Exception = e.Message;
         return(View());
     }
 }
Пример #18
0
 public ActionResult Addnotice(tbl_NoticeBoardMasterss model, HttpPostedFileBase image)
 {
     try
     {
         if (model.pkid == 0)
         {
             tbl_NoticeBoardMaster abc = new tbl_NoticeBoardMaster();
             if (image != null)
             {
                 WebFunction web = new WebFunction();
                 model.Image_Path = web.Storefile(image, 2);
             }
             abc.NoticeName        = model.NoticeName;
             abc.NoticeDescription = model.NoticeDescription;
             abc.Image_Path        = model.Image_Path;
             abc.AddedDate         = DateTime.Now;
             abc.RequiredDays      = model.RequiredDays;
             abc.Active            = model.Active;
             abc.LastModifiedDate  = DateTime.Now;
             _notice.Add(abc);
         }
         else
         {
             int _id = Convert.ToInt32(model.pkid);
             tbl_NoticeBoardMaster abc = _notice.Get(_id);
             if (image != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.Image_Path);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 WebFunction web = new WebFunction();
                 model.Image_Path = web.Storefile(image, 2);
             }
             abc.pkid              = model.pkid;
             abc.NoticeName        = model.NoticeName;
             abc.NoticeDescription = model.NoticeDescription;
             abc.Image_Path        = model.Image_Path;
             abc.AddedDate         = model.AddedDate;
             abc.RequiredDays      = model.RequiredDays;
             abc.Active            = model.Active;
             abc.LastModifiedDate  = DateTime.Now;
             _notice.Update(abc);
         }
         return(RedirectToAction("Addnotice", "Administration"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         ViewBag.Exception = e.Message;
         return(View());
     }
 }
Пример #19
0
        public ObjectResult Relationships(ServiceKeyWeb postData)
        {
            return(WebFunction.Execute <ServiceKeyWeb, ServiceRelationshipWeb[]>(this, postData, (sv) =>
            {
                var key = new ServiceKey(sv);
                var config = ServiceRelationships.Get(key);

                var svcRel = config.Select(def => def.GetDefinition(key)).Where(pd => pd != null).ToList();
                var answer = svcRel.Select(rel => rel.ToWeb()).ToArray();

                return new WebResult <ServiceRelationshipWeb[]>(answer);
            }));
        }
Пример #20
0
        public ActionResult DeleteNews(int id)
        {
            try
            {
                WebFunction        web = new WebFunction();
                tbl_NewsAndUpdated abc = _news.Get(id);
                _tourim.Remove(id, false);

                return(RedirectToAction("NewsAndUpdated", "Administration"));
            }
            catch
            {
                return(RedirectToAction("NewsAndUpdated", "Administration"));
            }
        }
Пример #21
0
        public ObjectResult Validate(ServiceKeyWeb postData)
        {
            return(WebFunction.Execute <ServiceKeyWeb, ValidateServiceResponseWeb>(this, postData, (sv) =>
            {
                var key = new ServiceKey(sv);
                var config = ServiceConfiguration.Get(key.Id, key.EffectiveDate);

                ValidateServiceResponse answer = config.Validate(key);

                return new WebResult <ValidateServiceResponseWeb>(new ValidateServiceResponseWeb(answer));
            }, (ex) =>
            {
                return new WebResult <ValidateServiceResponseWeb>(new ValidateServiceResponseWeb(ex));
            }));
        }
Пример #22
0
        public object Execute()
        {
            if (string.IsNullOrEmpty(Cmd))
            {
                return(null);
            }

            WebFunction func = FunctionConvert.GetFunction(Cmd);

            if (func != null)
            {
                return(func(Arg, Args));
            }
            else
            {
                return(null);
            }
        }
Пример #23
0
 public ActionResult DeleteTourism(int id)
 {
     try
     {
         WebFunction                   web  = new WebFunction();
         tbl_TourismMaster             abc  = _tourim.Get(id);
         List <tbl_MultipleFileUpload> file = _mfile.GetAll().Where(x => x.SubMaster_fkid == abc.pkid).ToList();
         foreach (var item in file)
         {
             web.DeleteImage(item.filepath);
             _mfile.Remove(item, true);
         }
         _tourim.Remove(id, true);
         return(Json("success", JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(Json("failed", JsonRequestBehavior.AllowGet));
     }
 }
Пример #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Int32 recordcount;

        TopHtml.InnerHtml = BaseClass.ShowStaticLabel("Label=WEB_网站顶部", "curr=1").ToString();
        footor.InnerHtml  = BaseClass.ShowStaticLabel("Label=WEB_网站底部").ToString();
        //newsleftShow.InnerHtml = BaseClass.ShowStaticLabel("Label=WEB_新闻左侧页面").ToString();
        //hotnewShow.InnerHtml = BaseClass.ShowListLabel(out recordcount, "Label=WEB_热点排行新闻列表", "NodeId=83", "startRow=0", "LastRowNum=10").ToString();
        NewsBind();
        string ID = Request.QueryString["NODEID"];

        if ("".Equals(ID) || ID == null)
        {
            ID = "83";
        }
        int i = 0;

        if (int.TryParse(ID, out i))
        {
            nodename = WebFunction.GetNodeName(ID).ToString();
        }
    }
Пример #25
0
        public ObjectResult Attributes(ServiceAttributesKeyWeb postData)
        {
            return(WebFunction.Execute <ServiceAttributesKeyWeb, AttributeInfoWeb[]>(this, postData, (sa) =>
            {
                AttributeInfoWeb[] list;

                if (sa == null)
                {
                    list = new AttributeInfoWeb[1];
                    list[0] = new AttributeInfoWeb {
                        ErrorString = "Key cannot be null", IsValid = false
                    };

                    return new WebResult <AttributeInfoWeb[]>(list);
                }
                var sKey = new ServiceKey(sa);
                try
                {
                    var atts = ServiceAttributes.Get(sKey, sa.PopulateLists);
                    list = new AttributeInfoWeb[atts.Count];
                    var i = 0;
                    foreach (var att in atts)
                    {
                        list[i++] = new AttributeInfoWeb(att);
                    }
                }
                catch (Exception e)
                {
                    list = new AttributeInfoWeb[1];
                    list[0] = new AttributeInfoWeb {
                        ErrorString = e.Message, IsValid = false
                    };
                }

                return new WebResult <AttributeInfoWeb[]>(list);
            }));
        }
        public async Task <IHttpActionResult> EditUserProfile()
        {
            WMC_WebApplicationEntities db = new WMC_WebApplicationEntities();

            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var provider = await Request.Content.ReadAsMultipartAsync <InMemoryMultipartFormDataStreamProvider>(new InMemoryMultipartFormDataStreamProvider());

            //access form data
            NameValueCollection model = provider.FormData;
            //access files
            IList <HttpContent> files = provider.Files;


            returnAPiFlag   abcd = new returnAPiFlag();
            tbl_UserDetails abc  = new tbl_UserDetails();

            try
            {
                abc.pkid          = Convert.ToInt32(model["pkid"]);
                abc.FullName      = model["FullName"];
                abc.AddressLine1  = model["AddressLine1"];
                abc.AddressLine2  = model["AddressLine2"];
                abc.ContactNumber = model["ContactNumber"];
                abc.EmailId       = model["EmailId"];
                abc.ProdilePic    = model["ProdilePic"];
            }
            catch (Exception e)
            {
                abcd.status = e.Message;
                abcd.flag   = true;
                return(Json(abcd));
            }
            try
            {
                string id;
                id = User.Identity.GetUserId();
                id = RequestContext.Principal.Identity.GetUserId();

                if (abc.pkid == 0)
                {
                    abcd.status = "pkid is Required for Edit";
                    abcd.flag   = false;
                }
                else
                {
                    var editdata = db.tbl_UserDetails.Where(x => x.pkid == abc.pkid).FirstOrDefault();

                    var httpRequest = HttpContext.Current.Request;
                    if (httpRequest.Files.Count > 0)
                    {
                        var docfiles = new List <string>();
                        for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                        {
                            WebFunction web        = new WebFunction();
                            var         postedFile = httpRequest.Files[i];
                            DateTime    date       = DateTime.Now;
                            string      dates      = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                            var         returnpath = "/UploadFiles/Userspic/" + dates + postedFile.FileName;
                            var         filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Userspic/"), dates + postedFile.FileName);
                            postedFile.SaveAs(filePath);
                            editdata.ProdilePic = returnpath;
                        }
                    }
                    editdata.FullName         = abc.FullName;
                    editdata.ContactNumber    = abc.ContactNumber;
                    editdata.AddressLine1     = abc.AddressLine1;
                    editdata.AddressLine2     = abc.AddressLine2;
                    editdata.EmailId          = abc.EmailId;
                    editdata.LastModifiedDate = DateTime.Now;
                    db.tbl_UserDetails.Attach(editdata);
                    db.Entry(editdata).State = EntityState.Modified;
                    db.SaveChanges();
                    abcd.status = "Data updated Successfully";
                    abcd.flag   = true;
                }
                return(Json(abcd));
            }
            catch (Exception e)
            {
                abcd.status = e.Message;
                abcd.flag   = false;
                return(Json(abc));
            }
        }
        public ActionResult UploadExcel(QuestionMaster model)
        {
            ViewBag.QueTypeList = new SelectList(_subtype.GetAll().Where(x => x.pkid != 4).ToList(), "pkid", "Questiontype");
            ViewBag.CourseList  = new SelectList(_course.GetAll(), "pkid", "CourseName");
            string exception = "";

            try
            {
                WebFunction        comm = new WebFunction();
                HttpPostedFileBase FileUpload = Request.Files[0];
                DataTable          dt = new DataTable();
                string             alert = "", msg = "";

                if (FileUpload != null)
                {
                    dt = comm.GetExcesData(FileUpload);

                    //   List<tbl_MonthlyLibility> monthlyLibalityList = new List<tbl_MonthlyLibility>();
                    int i = 1;
                    foreach (DataRow dr in dt.Rows.Cast <DataRow>().Skip(2))
                    {
                        if (model.Questtype_fkid == 5)
                        {
                            if (FileUpload.FileName == "Match_Content5.xlsx")
                            {
                                tbl_QuestionMaster QUESTION = new tbl_QuestionMaster();


                                var q = dr[1].ToString();
                                var A = dr[2].ToString();
                                QUESTION.subjecttype_fkid = Convert.ToInt32(dr[0]);
                                QUESTION.Question         = dr[1].ToString();
                                QUESTION.Explaination     = dr[2].ToString();
                                QUESTION.Subject_fkid     = Convert.ToInt32(dr[3]);
                                QUESTION.Division_fkid    = Convert.ToInt32(dr[4]);
                                QUESTION.hint             = dr[5].ToString();
                                QUESTION.Marks            = Convert.ToDecimal(dr[6]);
                                try { QUESTION.NegativeMarks = Convert.ToDecimal(dr[7]); }
                                catch { QUESTION.NegativeMarks = 0; }

                                QUESTION.SelectLevel  = Convert.ToInt32(dr[8]);
                                QUESTION.Adddate      = DateTime.Now;
                                QUESTION.Status       = 1;
                                QUESTION.lastModified = DateTime.Now;
                                _question.Add(QUESTION);

                                int _Maxid = _question.GetAll().Max(x => x.pkid);
                                for (int p = 1; p <= 10; p++)
                                {
                                    tbl_MatchContentQuestionMaster ANSWER = new tbl_MatchContentQuestionMaster();
                                    int AA = 0; int BB = 0; int CC = 0;
                                    if (p == 1)
                                    {
                                        AA = 9; BB = 10; CC = 11;
                                    }
                                    else if (p == 2)
                                    {
                                        AA = 12; BB = 13; CC = 14;
                                    }
                                    else if (p == 3)
                                    {
                                        AA = 15; BB = 16; CC = 17;
                                    }
                                    else if (p == 4)
                                    {
                                        AA = 18; BB = 19; CC = 20;
                                    }
                                    else if (p == 5)
                                    {
                                        AA = 21; BB = 22; CC = 23;
                                    }
                                    else if (p == 6)
                                    {
                                        AA = 24; BB = 25; CC = 26;
                                    }
                                    else if (p == 7)
                                    {
                                        AA = 27; BB = 28; CC = 29;
                                    }
                                    else if (p == 8)
                                    {
                                        AA = 30; BB = 31; CC = 32;
                                    }
                                    else if (p == 9)
                                    {
                                        AA = 33; BB = 34; CC = 35;
                                    }
                                    else
                                    {
                                        AA = 36; BB = 37; CC = 38;
                                    }

                                    ANSWER.Ques_fkid       = _Maxid;
                                    ANSWER.FirstColoumn    = dr[AA].ToString();
                                    ANSWER.OppositeColoumn = dr[BB].ToString();
                                    ANSWER.AnsweColoumn    = dr[CC].ToString();
                                    ANSWER.LastDatetime    = DateTime.Now;
                                    if (!string.IsNullOrWhiteSpace(ANSWER.FirstColoumn) && !string.IsNullOrWhiteSpace(ANSWER.OppositeColoumn) && !string.IsNullOrWhiteSpace(ANSWER.AnsweColoumn))
                                    {
                                        _Matc.Add(ANSWER);
                                    }
                                }
                            }
                            else
                            {
                                exception = "Select Correct File.";
                                return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception }));
                            }
                        }
                        else if (model.Questtype_fkid == 7)
                        {
                            if (FileUpload.FileName == "Full_Form7.xlsx")
                            {
                                tbl_QuestionMaster QUESTION = new tbl_QuestionMaster();

                                var q = dr[1].ToString();
                                var A = dr[2].ToString();
                                QUESTION.subjecttype_fkid = Convert.ToInt32(dr[0]);
                                QUESTION.Question         = dr[1].ToString();
                                QUESTION.Explaination     = dr[2].ToString();
                                QUESTION.Subject_fkid     = Convert.ToInt32(dr[3]);
                                QUESTION.Division_fkid    = Convert.ToInt32(dr[4]);
                                QUESTION.hint             = dr[5].ToString();
                                QUESTION.Marks            = Convert.ToDecimal(dr[6]);
                                try { QUESTION.NegativeMarks = Convert.ToDecimal(dr[7]); }
                                catch { QUESTION.NegativeMarks = 0; }

                                QUESTION.SelectLevel  = Convert.ToInt32(dr[8]);
                                QUESTION.Adddate      = DateTime.Now;
                                QUESTION.Status       = 1;
                                QUESTION.lastModified = DateTime.Now;
                                _question.Add(QUESTION);

                                int _Maxid = _question.GetAll().Max(x => x.pkid);
                                for (int p = 1; p <= 10; p++)
                                {
                                    tbl_MatchContentQuestionMaster ANSWER = new tbl_MatchContentQuestionMaster();
                                    int AA = 0; int CC = 0;
                                    if (p == 1)
                                    {
                                        AA = 9; CC = 10;
                                    }
                                    else if (p == 2)
                                    {
                                        AA = 11; CC = 12;
                                    }
                                    else if (p == 3)
                                    {
                                        AA = 13; CC = 14;
                                    }
                                    else if (p == 4)
                                    {
                                        AA = 15; CC = 16;
                                    }
                                    else if (p == 5)
                                    {
                                        AA = 17; CC = 18;
                                    }
                                    else if (p == 6)
                                    {
                                        AA = 19; CC = 20;
                                    }
                                    else if (p == 7)
                                    {
                                        AA = 21; CC = 22;
                                    }
                                    else if (p == 8)
                                    {
                                        AA = 23; CC = 24;
                                    }
                                    else if (p == 9)
                                    {
                                        AA = 25; CC = 26;
                                    }
                                    else
                                    {
                                        AA = 27; CC = 28;
                                    }


                                    ANSWER.Ques_fkid    = _Maxid;
                                    ANSWER.FirstColoumn = dr[AA].ToString();
                                    ANSWER.AnsweColoumn = dr[CC].ToString();
                                    ANSWER.LastDatetime = DateTime.Now;
                                    if (!string.IsNullOrWhiteSpace(ANSWER.FirstColoumn) && !string.IsNullOrWhiteSpace(ANSWER.AnsweColoumn))
                                    {
                                        _Matc.Add(ANSWER);
                                    }
                                }
                            }
                            else
                            {
                                exception = "Select Correct File.";
                                return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception }));
                            }
                        }
                        else
                        {
                            if (FileUpload.FileName == "QuestionAnswer.xlsx")
                            {
                                tbl_QuestionMaster QUESTION = new tbl_QuestionMaster();
                                tbl_AnswerMaster   ANSWER   = new tbl_AnswerMaster();

                                var q = dr[1].ToString();
                                var A = dr[2].ToString();
                                QUESTION.subjecttype_fkid = Convert.ToInt32(dr[0]);
                                QUESTION.Question         = dr[1].ToString();
                                QUESTION.Explaination     = dr[2].ToString();
                                QUESTION.Subject_fkid     = Convert.ToInt32(dr[3]);
                                QUESTION.Division_fkid    = Convert.ToInt32(dr[4]);
                                QUESTION.hint             = dr[5].ToString();
                                QUESTION.Marks            = Convert.ToDecimal(dr[6]);
                                try { QUESTION.NegativeMarks = Convert.ToDecimal(dr[7]); }
                                catch { QUESTION.NegativeMarks = 0; }

                                QUESTION.SelectLevel  = Convert.ToInt32(dr[8]);
                                QUESTION.Adddate      = DateTime.Now;
                                QUESTION.Status       = 1;
                                QUESTION.lastModified = DateTime.Now;
                                _question.Add(QUESTION);
                                ANSWER.Ques_fkid      = _question.GetAll().Max(x => x.pkid);
                                ANSWER.Questtype_fkid = Convert.ToInt32(dr[0]);
                                ANSWER.Answer1        = dr[9].ToString();
                                ANSWER.Answer2        = dr[10].ToString();
                                ANSWER.Answer3        = dr[11].ToString();
                                ANSWER.Answer4        = dr[12].ToString();
                                try { ANSWER.CorrectAnswer = Convert.ToInt32(dr[13]); }
                                catch { }

                                ANSWER.BlanckSpace = dr[14].ToString();
                                try { ANSWER.TrueFalse = Convert.ToBoolean(dr[15]); }
                                catch { }
                                ANSWER.Adddate      = DateTime.Now;
                                ANSWER.status       = 1;
                                ANSWER.lastmodified = DateTime.Now;
                                _answer.Add(ANSWER);
                            }
                            else
                            {
                                exception = "Select Correct File.";
                                return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception }));
                            }
                        }
                    }
                    exception = "All Data Uploaded Successfully";
                }
                else
                {
                    exception = "Please select File.";
                }

                return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception }));
            }
            catch (Exception e)
            {
                Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
                exception = e.Message;
                return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception }));
            }
        }
        public ActionResult AddQuestion(QuestionMaster model)
        {
            WebFunction web       = new WebFunction();
            string      exception = "";

            try
            {
                if (model.pkid == 0)
                {
                    tbl_QuestionMaster abc = new tbl_QuestionMaster();
                    abc.subjecttype_fkid = model.Questtype_fkid;
                    abc.Question         = model.Question;
                    abc.Explaination     = model.Explaination;
                    abc.Subject_fkid     = model.Subject_fkid;
                    abc.Division_fkid    = model.Division_fkid;
                    abc.hint             = model.hint;
                    abc.SelectLevel      = model.SelectLevel;
                    abc.NegativeMarks    = model.NegativeMarks;
                    abc.Marks            = model.Marks;
                    abc.Status           = 1;
                    abc.Adddate          = DateTime.Now;
                    abc.lastModified     = DateTime.Now;
                    _question.Add(abc);
                    int Maxid = _question.GetAll().Max(x => x.pkid);
                    if (model.Questtype_fkid == 5)
                    {
                        foreach (var item in model.MATContent)
                        {
                            if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.OppositeColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn))
                            {
                                tbl_MatchContentQuestionMaster MA = new tbl_MatchContentQuestionMaster();
                                MA.Ques_fkid       = Maxid;
                                MA.FirstColoumn    = item.FirstColoumn;
                                MA.OppositeColoumn = item.OppositeColoumn;
                                MA.AnsweColoumn    = item.AnsweColoumn;
                                MA.LastDatetime    = DateTime.Now;
                                _Matc.Add(MA);
                            }
                        }
                    }
                    else if (model.Questtype_fkid == 7)
                    {
                        foreach (var item in model.FULLF)
                        {
                            if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn))
                            {
                                tbl_MatchContentQuestionMaster MA = new tbl_MatchContentQuestionMaster();
                                MA.Ques_fkid    = Maxid;
                                MA.FirstColoumn = item.FirstColoumn;
                                MA.AnsweColoumn = item.AnsweColoumn;
                                MA.LastDatetime = DateTime.Now;
                                _Matc.Add(MA);
                            }
                        }
                    }
                    else if (model.Questtype_fkid == 6)
                    {
                        tbl_AnswerMaster ANS = new tbl_AnswerMaster();
                        ANS.Ques_fkid      = _question.GetAll().Max(x => x.pkid);
                        ANS.Questtype_fkid = model.Questtype_fkid;
                        var httpRequest = System.Web.HttpContext.Current.Request;
                        if (httpRequest.Files.Count > 0)
                        {
                            var docfiles = new List <string>();
                            for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                            {
                                string path       = "";
                                var    postedFile = httpRequest.Files[i];
                                if (i == 0)
                                {
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer1 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                                else if (i == 1)
                                {
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer2 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                                else if (i == 2)
                                {
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer3 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                                else if (i == 3)
                                {
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer4 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                            }
                        }
                        ANS.CorrectAnswer = model.CorrectAnswerDD;
                        ANS.BlanckSpace   = model.BlanckSpace;
                        ANS.TrueFalse     = model.TrueFalse;
                        ANS.SubAnswer     = model.SubAnswer;
                        ANS.status        = 1;
                        ANS.Adddate       = DateTime.Now;
                        ANS.lastmodified  = DateTime.Now;
                        _answer.Add(ANS);
                        exception = "Save Successfully";
                    }
                    else
                    {
                        tbl_AnswerMaster ANS = new tbl_AnswerMaster();
                        ANS.Ques_fkid      = _question.GetAll().Max(x => x.pkid);
                        ANS.Questtype_fkid = model.Questtype_fkid;
                        ANS.Answer1        = model.Answer1;
                        ANS.Answer2        = model.Answer2;
                        ANS.Answer3        = model.Answer3;
                        ANS.Answer4        = model.Answer4;
                        ANS.CorrectAnswer  = model.CorrectAnswerDD;
                        ANS.BlanckSpace    = model.BlanckSpace;
                        ANS.TrueFalse      = model.TrueFalse;
                        ANS.SubAnswer      = model.SubAnswer;
                        ANS.status         = 1;
                        ANS.Adddate        = DateTime.Now;
                        ANS.lastmodified   = DateTime.Now;
                        _answer.Add(ANS);
                        exception = "Save Successfully";
                    }
                }
                else
                {
                    int _id = Convert.ToInt32(model.pkid);
                    tbl_QuestionMaster abc = _question.Get(_id);
                    abc.subjecttype_fkid = model.Questtype_fkid;
                    abc.Division_fkid    = model.Division_fkid;
                    abc.Question         = model.Question;
                    abc.Explaination     = model.Explaination;
                    abc.Subject_fkid     = model.Subject_fkid;
                    abc.Division_fkid    = model.Division_fkid;
                    abc.hint             = model.hint;
                    abc.SelectLevel      = model.SelectLevel;
                    abc.SelectLevel      = model.SelectLevel;
                    abc.NegativeMarks    = model.NegativeMarks;
                    abc.Marks            = model.Marks;
                    abc.Status           = model.Status;
                    abc.Adddate          = model.Adddate;
                    abc.lastModified     = DateTime.Now;
                    _question.Update(abc);

                    if (model.Questtype_fkid == 5)
                    {
                        foreach (var item in model.MATContent)
                        {
                            if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.OppositeColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn))
                            {
                                tbl_MatchContentQuestionMaster MA = _Matc.Get(item.pkid);
                                MA.FirstColoumn    = item.FirstColoumn;
                                MA.OppositeColoumn = item.OppositeColoumn;
                                MA.AnsweColoumn    = item.AnsweColoumn;
                                MA.LastDatetime    = DateTime.Now;
                                _Matc.Update(MA);
                            }
                        }
                    }
                    else if (model.Questtype_fkid == 7)
                    {
                        foreach (var item in model.FULLF)
                        {
                            if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn))
                            {
                                tbl_MatchContentQuestionMaster MA = _Matc.Get(item.pkid);
                                MA.FirstColoumn = item.FirstColoumn;
                                MA.AnsweColoumn = item.AnsweColoumn;
                                MA.LastDatetime = DateTime.Now;
                                _Matc.Update(MA);
                            }
                        }
                    }
                    else if (model.Questtype_fkid == 6)
                    {
                        tbl_AnswerMaster ANS = _answer.GetAll().Where(x => x.Ques_fkid == _id).FirstOrDefault();
                        ANS.Ques_fkid      = _id;
                        ANS.Questtype_fkid = model.Questtype_fkid;
                        var httpRequest = System.Web.HttpContext.Current.Request;
                        if (httpRequest.Files.Count > 0)
                        {
                            var docfiles = new List <string>();
                            for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                            {
                                string path       = "";
                                var    postedFile = httpRequest.Files[i];
                                if (i == 0)
                                {
                                    if (System.IO.File.Exists(ANS.Answer1))
                                    {
                                        System.IO.File.Delete(ANS.Answer1);
                                    }
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer1 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                                else if (i == 1)
                                {
                                    if (System.IO.File.Exists(ANS.Answer2))
                                    {
                                        System.IO.File.Delete(ANS.Answer2);
                                    }
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer2 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                                else if (i == 2)
                                {
                                    if (System.IO.File.Exists(ANS.Answer3))
                                    {
                                        System.IO.File.Delete(ANS.Answer3);
                                    }
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer3 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                                else if (i == 3)
                                {
                                    if (System.IO.File.Exists(ANS.Answer4))
                                    {
                                        System.IO.File.Delete(ANS.Answer4);
                                    }
                                    DateTime date  = DateTime.Now;
                                    string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                                    ANS.Answer4 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName;
                                    path        = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName);
                                    postedFile.SaveAs(path);
                                }
                            }
                        }
                        ANS.CorrectAnswer = model.CorrectAnswerDD;
                        ANS.BlanckSpace   = model.BlanckSpace;
                        ANS.TrueFalse     = model.TrueFalse;
                        ANS.SubAnswer     = model.SubAnswer;
                        ANS.status        = 1;
                        ANS.Adddate       = DateTime.Now;
                        ANS.lastmodified  = DateTime.Now;
                        _answer.Update(ANS);
                        exception = "Save Successfully";
                    }
                    else
                    {
                        tbl_AnswerMaster ANS = _answer.GetAll().Where(x => x.Ques_fkid == model.pkid).FirstOrDefault();
                        ANS.Questtype_fkid = model.Questtype_fkid;
                        ANS.Answer1        = model.Answer1;
                        ANS.Answer2        = model.Answer2;
                        ANS.Answer3        = model.Answer3;
                        ANS.Answer4        = model.Answer4;
                        ANS.CorrectAnswer  = model.CorrectAnswerDD;
                        ANS.BlanckSpace    = model.BlanckSpace;
                        ANS.TrueFalse      = model.TrueFalse;
                        ANS.SubAnswer      = model.SubAnswer;
                        ANS.status         = 1;
                        ANS.Adddate        = DateTime.Now;
                        ANS.lastmodified   = DateTime.Now;
                        _answer.Update(ANS);
                    }
                    exception = "Updated Successfully";
                }
                return(RedirectToAction("AddQuestion", "SubjectGroup", new { Exception = exception }));
            }
            catch (Exception e)
            {
                Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
                exception = e.Message;
                return(RedirectToAction("AddQuestion", "SubjectGroup", new { Exception = exception }));
            }
        }
        public async Task <IHttpActionResult> SaveSuggestion()
        {
            WMC_WebApplicationEntities db = new WMC_WebApplicationEntities();

            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var provider = await Request.Content.ReadAsMultipartAsync <InMemoryMultipartFormDataStreamProvider>(new InMemoryMultipartFormDataStreamProvider());

            //access form data
            NameValueCollection model = provider.FormData;
            //access files
            IList <HttpContent> files = provider.Files;


            returnAPiFlag        abcd = new returnAPiFlag();
            tbl_suggestionMaster abc  = new tbl_suggestionMaster();

            try
            {
                abc.pkd         = Convert.ToInt32(model["pkd"]);
                abc.title       = model["title"];
                abc.description = model["description"];
                abc.adddate     = DateTime.Now;
                abc.status      = 1;
            }
            catch
            {
                abcd.status = "Entered Required Field";
                abcd.flag   = true;
                return(Json(abcd));
            }
            try
            {
                string id;
                id = User.Identity.GetUserId();
                id = RequestContext.Principal.Identity.GetUserId();

                if (abc.pkd == 0)
                {
                    var httpRequest = HttpContext.Current.Request;
                    if (httpRequest.Files.Count > 0)
                    {
                        var docfiles = new List <string>();
                        for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                        {
                            WebFunction web        = new WebFunction();
                            var         postedFile = httpRequest.Files[i];
                            DateTime    date       = DateTime.Now;
                            string      dates      = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                            var         returnpath = "/UploadFiles/Suggestion/" + dates + postedFile.FileName;
                            var         filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Suggestion/"), dates + postedFile.FileName);
                            postedFile.SaveAs(filePath);
                            abc.imagepath = returnpath;
                        }
                    }

                    abc.user_fkid = id;
                    db.tbl_suggestionMaster.Add(abc);
                    db.SaveChanges();
                    abcd.status = "Data Save Successfully";
                    abcd.flag   = true;
                }
                else
                {
                    var httpRequest = HttpContext.Current.Request;
                    if (httpRequest.Files.Count > 0)
                    {
                        var docfiles = new List <string>();
                        for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                        {
                            WebFunction web        = new WebFunction();
                            var         postedFile = httpRequest.Files[i];
                            DateTime    date       = DateTime.Now;
                            string      dates      = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                            var         returnpath = "/UploadFiles/Suggestion/" + dates + postedFile.FileName;
                            var         filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Suggestion/"), dates + postedFile.FileName);
                            postedFile.SaveAs(filePath);
                            abc.imagepath = returnpath;
                        }
                    }
                    db.tbl_suggestionMaster.Attach(abc);
                    db.Entry(model).State = EntityState.Modified;
                    db.SaveChanges();
                    abcd.status = "Data updated Successfully";
                    abcd.flag   = true;
                }
                return(Json(abcd));
            }
            catch (Exception e)
            {
                abcd.status = "Data Save Failed";
                abcd.flag   = false;
                return(Json(abc));
            }
        }
Пример #30
0
        public ActionResult AddStudent(tbl_StudentMasterss model, HttpPostedFileBase Mcopy, HttpPostedFileBase BIODATA, HttpPostedFileBase Medicalcer)
        {
            WebFunction web       = new WebFunction();
            string      exception = "";

            try
            {
                if (model.pkid == 0)
                {
                    tbl_StudentMaster abc = new tbl_StudentMaster();
                    if (Mcopy != null)
                    {
                        abc.Movement_copy = web.Storefile(Mcopy, 2);
                    }
                    if (BIODATA != null)
                    {
                        abc.BIODataForm = web.Storefile(BIODATA, 2);
                    }
                    if (Medicalcer != null)
                    {
                        abc.MedicalCertificate = web.Storefile(Medicalcer, 2);
                    }
                    abc.Course_fkid       = model.Course_fkid;
                    abc.Division_fkid     = model.Division_fkid;
                    abc.Force_fkid        = model.Force_fkid;
                    abc.UserName          = model.UserName;
                    abc.Password          = model.Password;
                    abc.ConfirmedPassword = model.ConfirmedPassword;
                    abc.CommisionNo       = model.CommisionNo;
                    abc.DateComm          = model.DateComm;
                    abc.Rank                    = model.Rank;
                    abc.FullName                = model.FullName;
                    abc.DateOfBirth             = model.DateOfBirth;
                    abc.PlaceOfBirth            = model.PlaceOfBirth;
                    abc.IdentificationMarks     = model.IdentificationMarks;
                    abc.Height                  = model.Height;
                    abc.Weight                  = model.Weight;
                    abc.ColorOfEye              = model.ColorOfEye;
                    abc.ColorOfHair             = model.ColorOfHair;
                    abc.Religion                = model.Religion;
                    abc.Caste                   = model.Caste;
                    abc.Nationality             = model.Nationality;
                    abc.UnitAndLocation         = model.UnitAndLocation;
                    abc.HQGroup                 = model.HQGroup;
                    abc.Directorate             = model.Directorate;
                    abc.State                   = model.State;
                    abc.CourseSeries            = model.CourseSeries;
                    abc.ChestNo                 = model.ChestNo;
                    abc.DUCFrom                 = model.DUCFrom;
                    abc.DUCTo                   = model.DUCTo;
                    abc.ArrivalInNCCOTA         = model.ArrivalInNCCOTA;
                    abc.MotherToughe            = model.MotherToughe;
                    abc.PresentAddress          = model.PresentAddress;
                    abc.ParmanentAddress        = model.ParmanentAddress;
                    abc.MaritalStatus           = model.MaritalStatus;
                    abc.NOKFullName             = model.NOKFullName;
                    abc.NOKAddress              = model.NOKAddress;
                    abc.NOKRelation             = model.NOKRelation;
                    abc.TeachingInstitideName   = model.TeachingInstitideName;
                    abc.TeachingSubject         = model.TeachingSubject;
                    abc.TeachingDateOfEmplyment = model.TeachingDateOfEmplyment;
                    abc.TeachingEmpStatus       = model.TeachingEmpStatus;
                    abc.NCCorOTUMember          = model.NCCorOTUMember;
                    abc.WhichDivision           = model.WhichDivision;
                    abc.WhichForce              = model.WhichForce;
                    abc.TrainingPeriod          = model.TrainingPeriod;
                    abc.RankofNCC               = model.RankofNCC;
                    abc.MedicallyExamined       = model.MedicallyExamined;
                    abc.AlimentName             = model.AlimentName;
                    abc.MovementOrderNo         = model.MovementOrderNo;
                    abc.MovementDate            = model.MovementDate;
                    abc.Games                   = model.Games;
                    abc.OtherQualification      = model.OtherQualification;
                    abc.ReadNCCActRules         = model.ReadNCCActRules;
                    abc.ReadNCCorDG             = model.ReadNCCorDG;
                    abc.ReadSyllabus            = model.ReadSyllabus;
                    abc.ReadHandbook            = model.ReadHandbook;
                    abc.ReadNCCCompPlanning     = model.ReadNCCCompPlanning;
                    abc.ReadNCCCompInstruction  = model.ReadNCCCompInstruction;
                    abc.DateOfPreCourseTraining = model.DateOfPreCourseTraining;
                    abc.Place                   = model.Place;
                    abc.AddedDate               = DateTime.Now;
                    _student.Add(abc);
                    exception = "Save Successfully";
                }
                else
                {
                    int _id = Convert.ToInt32(model.pkid);
                    tbl_StudentMaster abc = _student.Get(_id);
                    if (Mcopy != null)
                    {
                        if (model.Movement_copy != null)
                        {
                            web.DeleteImage(model.Movement_copy);
                        }

                        abc.Movement_copy = web.Storefile(Mcopy, 2);
                    }
                    if (BIODATA != null)
                    {
                        if (model.BIODataForm != null)
                        {
                            web.DeleteImage(model.BIODataForm);
                        }

                        abc.BIODataForm = web.Storefile(BIODATA, 2);
                    }
                    if (Medicalcer != null)
                    {
                        if (model.MedicalCertificate != null)
                        {
                            web.DeleteImage(model.MedicalCertificate);
                        }

                        abc.MedicalCertificate = web.Storefile(Medicalcer, 2);
                    }
                    abc.Course_fkid       = model.Course_fkid;
                    abc.Division_fkid     = model.Division_fkid;
                    abc.Force_fkid        = model.Force_fkid;
                    abc.UserName          = model.UserName;
                    abc.Password          = model.Password;
                    abc.ConfirmedPassword = model.ConfirmedPassword;
                    abc.CommisionNo       = model.CommisionNo;
                    abc.DateComm          = model.DateComm;
                    abc.Rank                    = model.Rank;
                    abc.FullName                = model.FullName;
                    abc.DateOfBirth             = model.DateOfBirth;
                    abc.PlaceOfBirth            = model.PlaceOfBirth;
                    abc.IdentificationMarks     = model.IdentificationMarks;
                    abc.Height                  = model.Height;
                    abc.Weight                  = model.Weight;
                    abc.ColorOfEye              = model.ColorOfEye;
                    abc.ColorOfHair             = model.ColorOfHair;
                    abc.Religion                = model.Religion;
                    abc.Caste                   = model.Caste;
                    abc.Nationality             = model.Nationality;
                    abc.UnitAndLocation         = model.UnitAndLocation;
                    abc.HQGroup                 = model.HQGroup;
                    abc.Directorate             = model.Directorate;
                    abc.State                   = model.State;
                    abc.CourseSeries            = model.CourseSeries;
                    abc.ChestNo                 = model.ChestNo;
                    abc.DUCFrom                 = model.DUCFrom;
                    abc.DUCTo                   = model.DUCTo;
                    abc.ArrivalInNCCOTA         = model.ArrivalInNCCOTA;
                    abc.MotherToughe            = model.MotherToughe;
                    abc.PresentAddress          = model.PresentAddress;
                    abc.ParmanentAddress        = model.ParmanentAddress;
                    abc.MaritalStatus           = model.MaritalStatus;
                    abc.NOKFullName             = model.NOKFullName;
                    abc.NOKAddress              = model.NOKAddress;
                    abc.NOKRelation             = model.NOKRelation;
                    abc.TeachingInstitideName   = model.TeachingInstitideName;
                    abc.TeachingSubject         = model.TeachingSubject;
                    abc.TeachingDateOfEmplyment = model.TeachingDateOfEmplyment;
                    abc.TeachingEmpStatus       = model.TeachingEmpStatus;
                    abc.NCCorOTUMember          = model.NCCorOTUMember;
                    abc.WhichDivision           = model.WhichDivision;
                    abc.WhichForce              = model.WhichForce;
                    abc.TrainingPeriod          = model.TrainingPeriod;
                    abc.RankofNCC               = model.RankofNCC;
                    abc.MedicallyExamined       = model.MedicallyExamined;
                    abc.AlimentName             = model.AlimentName;
                    abc.MovementOrderNo         = model.MovementOrderNo;
                    abc.MovementDate            = model.MovementDate;
                    abc.Games                   = model.Games;
                    abc.OtherQualification      = model.OtherQualification;
                    abc.ReadNCCActRules         = model.ReadNCCActRules;
                    abc.ReadNCCorDG             = model.ReadNCCorDG;
                    abc.ReadSyllabus            = model.ReadSyllabus;
                    abc.ReadHandbook            = model.ReadHandbook;
                    abc.ReadNCCCompPlanning     = model.ReadNCCCompPlanning;
                    abc.ReadNCCCompInstruction  = model.ReadNCCCompInstruction;
                    abc.DateOfPreCourseTraining = model.DateOfPreCourseTraining;
                    abc.Place                   = model.Place;
                    abc.AddedDate               = DateTime.Now;
                    _student.Update(abc);
                    exception = "Updated Successfully";
                }
                return(RedirectToAction("StudentMaster", "Student", new { Exception = exception }));
            }
            catch (Exception e)
            {
                Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
                exception = e.Message;
                return(RedirectToAction("StudentMaster", "Student", new { Exception = exception }));
            }
        }