Ejemplo n.º 1
0
        public ActionResult NewEntry(EntryDetails details)
        {
            //Checking if the model's properties are all validated
            if (ModelState.IsValid)
            {
                try
                {
                    //Extract the user ID from the cookies
                    int      _userID = Convert.ToInt32(Session["UserID"]);
                    DBHelper helper  = new DBHelper();

                    //Creating the entry, expecting value of true for a successful insert
                    if (helper.CreateJournalEntry(_userID, details.EntryContent, details.MoodID, false))
                    {
                        return(RedirectToAction("EntrySuccess"));
                    }
                    else
                    {
                        //No exception and no errors but entry wasn't successful logic
                        return(RedirectToAction("ErrorPage", "Account", new { exceptionMessage = "Something went wrong, please try again later!" }));
                    }
                }
                //Catch the exception and pass its content onto the error page
                catch (Exception ex)
                {
                    return(RedirectToAction("ErrorPage", "Account", new { exceptionMessage = ex.Message }));
                }
            }
            //Check if today's card has already been filled
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            EntryDetails entryDetails = db.EntryDetails.Find(id);

            db.EntryDetails.Remove(entryDetails);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public void Insert(string key, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration)
 {
     Cache[key] = value;
     CacheEntryDetails[key] = new EntryDetails
     {
         AbsoluteExpiration = absoluteExpiration,
         SlidingExpiration = slidingExpiration
     };
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Id,Amount,Price,Subtotal,ProductID,EntryNoteID")] EntryDetails entryDetails)
 {
     if (ModelState.IsValid)
     {
         db.Entry(entryDetails).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EntryNoteID = new SelectList(db.EntryNote, "Id", "Id", entryDetails.EntryNoteID);
     ViewBag.ProductID   = new SelectList(db.Product, "Id", "Code", entryDetails.ProductID);
     return(View(entryDetails));
 }
Ejemplo n.º 5
0
    public EntryDetails ParseEntryDetails(
        string collectionName,
        IDictionary <string, object> entryData,
        string?contentId = null)
    {
        // Copied from MetadataBase so we use caches for the property acquisition
        var entryDetails = new EntryDetails();

        foreach (var item in entryData)
        {
            if (HasStructuralProperty(collectionName, item.Key))
            {
                entryDetails.AddProperty(item.Key, item.Value);
            }
            else if (HasNavigationProperty(collectionName, item.Key))
            {
                if (IsNavigationPropertyCollection(collectionName, item.Key))
                {
                    switch (item.Value)
                    {
                    case null:
                        entryDetails.AddLink(item.Key, null, contentId);
                        break;

                    case IEnumerable <object> collection:
                        foreach (var element in collection)
                        {
                            entryDetails.AddLink(item.Key, element, contentId);
                        }

                        break;
                    }
                }
                else
                {
                    entryDetails.AddLink(item.Key, item.Value, contentId);
                }
            }
            else if (IsOpenType(collectionName))
            {
                entryDetails.HasOpenTypeProperties = true;
                entryDetails.AddProperty(item.Key, item.Value);
            }
            else if (!IgnoreUnmappedProperties)
            {
                throw new UnresolvableObjectException(item.Key, $"No property or association found for [{item.Key}].");
            }
        }

        return(entryDetails);
    }
Ejemplo n.º 6
0
        // GET: EntryDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EntryDetails entryDetails = db.EntryDetails.Find(id);

            if (entryDetails == null)
            {
                return(HttpNotFound());
            }
            return(View(entryDetails));
        }
Ejemplo n.º 7
0
        private Metadata GetMetadata(EntryDetails entry)
        {
            var      category    = entry.ParentCatalogName;
            Metadata metadata    = new Metadata();
            var      resourcekey = "勘探知识库\\石油百科\\" + category + "\\" + entry.Id;

            metadata.IIId             = resourcekey.ToMD5();
            metadata.IndexedDate      = DateTime.Now;
            metadata.Thumbnail        = null;
            metadata.Fulltext         = entry.Contents;
            metadata.PageId           = "20";//展示页面模板注册:石油百科词条
            metadata.DataId           = entry.Id.ToString();
            metadata["dsn"]           = "石油百科";
            metadata.ShowType         = IndexShowType.Mixing.ToString();
            metadata["title"]         = entry.Name;
            metadata["subject"]       = null;
            metadata["abstract"]      = null;
            metadata["catalogue"]     = null;
            metadata["author"]        = entry.Author;
            metadata["submitter"]     = null;
            metadata["auditor"]       = null;
            metadata["createddate"]   = DateTime.Now;
            metadata["submitteddate"] = null;
            metadata["auditteddate"]  = null;
            metadata["status"]        = "已审核";
            metadata["frequency"]     = null;
            metadata["period"]        = null;
            metadata["basin"]         = null;
            metadata["firstlevel"]    = null;
            metadata["secondlevel"]   = null;
            metadata["trap"]          = null;
            metadata["well"]          = null;
            metadata["swa"]           = null;
            metadata["miningarea"]    = null;
            metadata["cozone"]        = null;
            metadata["project"]       = null;
            metadata["pc"]            = "石油百科";
            metadata["pt"]            = "石油百科词条";
            metadata["bd"]            = "勘探";
            metadata["bt"]            = null;
            metadata["bp"]            = null;
            metadata["ba"]            = null;
            metadata["bf"]            = null;
            metadata["system"]        = "勘探知识库";
            metadata["resourcetype"]  = "勘探知识库\\石油百科词条";
            metadata["resourcekey"]   = resourcekey;
            return(metadata);
        }
Ejemplo n.º 8
0
        // GET: EntryDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EntryDetails entryDetails = db.EntryDetails.Find(id);

            if (entryDetails == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EntryNoteID = new SelectList(db.EntryNote, "Id", "Id", entryDetails.EntryNoteID);
            ViewBag.ProductID   = new SelectList(db.Product, "Id", "Code", entryDetails.ProductID);
            return(View(entryDetails));
        }
Ejemplo n.º 9
0
        public ActionResult ViewSingleEntry(DateTime entryDate)
        {
            try
            {
                //Extract the user ID from the cookies
                int      _userID = Convert.ToInt32(Session["UserID"]);
                DBHelper helper  = new DBHelper();

                //Construct the details object
                EntryDetails details = helper.GetSingleEntry(entryDate, _userID);

                //Try to get the entry
                return(View(details));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("ErrorPage", "Account", new { exceptionMessage = ex.Message }));
            }
        }