Exemplo n.º 1
0
        public JsonResult ApproveEpins()
        {
            List <string> li = new List <string>();

            try
            {
                var epr = db.ePinRequests.ToArray();
                foreach (var item in epr)
                {
                    for (int i = 0; i < item.Qty; i++)
                    {
                        ePinCode ObjePinCode = new ePinCode();
                        ObjePinCode.DateAdded     = DateTime.Now;
                        ObjePinCode.ePinRequestId = item.Id;
                        Guid guid = Guid.NewGuid();
                        ObjePinCode.PCode = guid.ToString().Substring(0, 32);
                        db.ePinCodes.Add(ObjePinCode);
                        db.SaveChanges();
                    }
                    var ObjePinRequest = item;
                    ObjePinRequest.IsApproved      = true;
                    ObjePinRequest.ApprovedBy      = int.Parse(Env.GetUserInfo("userid"));
                    db.Entry(ObjePinRequest).State = EntityState.Modified;
                    db.SaveChanges();
                }

                li.Add("Done");
            }
            catch (Exception)
            {
                li.Add("Error");
            }
            return(Json(li, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult CommitTags(int fontId, [ModelBinder(typeof(ViewSymbolsBinder))] List <SymbolView> viewSymbols)
        {
            if (!Verifier.CheckLogin(Request))
            {
                return(RedirectToAction("Login", new { url = Request.Url.AbsoluteUri }));
            }

            var font = db.Fonts.Find(fontId);

            if (font == null)
            {
                return(HttpNotFound("font id was not found"));
            }

            List <string> strsTemp;
            var           tagsInDb = db.Tags.ToList();
            var           symbols  = font.Symbols.ToList();
            Symbol        symTemp;
            Tag           tagTemp;

            foreach (var child in viewSymbols)
            {
                if (string.IsNullOrEmpty(child.Tags))
                {
                    continue;
                }

                symTemp = symbols.Find(x => x.Id == child.Sid);
                if (symTemp == null)
                {
                    continue;
                }

                if (symTemp.Tags == null)
                {
                    symTemp.Tags = new List <Tag>();
                }
                else if (symTemp.Tags.Count > 0)
                {
                    symTemp.Tags.Clear();
                }


                strsTemp = child.Tags.Split(',').Select(s => s.Trim()).Distinct().ToList();
                foreach (var tagInClient in strsTemp)
                {
                    tagTemp = tagsInDb.Find(x => x.TagString == tagInClient);
                    if (tagTemp == null)
                    {
                        tagTemp = new Tag()
                        {
                            TagString = tagInClient
                        };

                        db.Tags.Add(tagTemp);
                        db.SaveChanges();
                    }

                    symTemp.Tags.Add(tagTemp);
                }


                db.Entry(symTemp).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                tagsInDb = db.Tags.ToList();
            }


            ViewData["fontCurrent"] = font;
            ViewData["symbols"]     = db.Symbols.Where(x => x.FontId == font.Id).ToList();
            return(PartialView("_FontSymbolsTBody"));
        }