public async Task <ActionResult <JournalModel> > PostJournalModel(JournalModel journalModel)
        {
            _context.JournalModel.Add(journalModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetJournalModel", new { id = journalModel.ID }, journalModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Thoughts,Gratitudes,Concerns,Questions")] JournalModel journalModel)
        {
            if (id != journalModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(journalModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JournalModelExists(journalModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(journalModel));
        }
Exemplo n.º 3
0
        public IHttpActionResult AddJournal(JournalModel journal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (CurrentUser == null || !CurrentUser.IsAdmin)
            {
                return(Unauthorized());
            }

            try
            {
                DataContext.Journals.InsertOnSubmit(new Journal()
                {
                    Title       = journal.Title,
                    Date        = journal.Date,
                    Periodicity = journal.Periodicity,
                    Amount      = journal.Amount,
                    Price       = journal.Price,
                    Subjects    = journal.Subjects,
                    PhotoId     = journal?.PhotoId
                });
                DataContext.SubmitChanges();
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }

            return(Ok());
        }
Exemplo n.º 4
0
        public JsonResult Create(JournalModel obj)
        {
            tblJournal model = new tblJournal();

            if (obj != null)
            {
                obj.TPage           = obj.EPage - obj.SPage;
                model.Id            = obj.id;
                model.Category      = obj.category;
                model.title         = obj.title;
                model.Noofauthor    = obj.Noofauthor;
                model.author1       = obj.author1;
                model.author2       = obj.author2;
                model.author3       = obj.author3;
                model.author4       = obj.author4;
                model.author5       = obj.author6;
                model.author6       = obj.author6;
                model.journalName   = obj.JournalNm;
                model.issueno       = obj.issueno;
                model.volumeno      = obj.volumeno;
                model.SPage         = obj.SPage;
                model.EPage         = obj.EPage;
                model.totalPage     = obj.TPage;
                model.pubName       = obj.pubName;
                model.Impact_Factor = obj.impactFactor;
                model.Country       = obj.Country;
                model.pubDate       = obj.PubDate;
                db.tblJournals.Add(model);
                db.SaveChanges();

                return(Json(obj));
            }
            return(Json("error", JsonRequestBehavior.AllowGet));
        }
        public async Task <IActionResult> PutJournalModel(int id, JournalModel journalModel)
        {
            if (id != journalModel.ID)
            {
                return(BadRequest());
            }

            _context.Entry(journalModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JournalModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 6
0
        public JsonResult Save(JournalModel model)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(JsonError("You are not authenticated"));
            }
            JourListDMContainer dm = new JourListDMContainer();

            var member = dm.Members.SingleOrDefault(z => z.Name == User.Identity.Name);

            if (member == null)
            {
                return(JsonError("You are not registered in the system"));
            }

            var journal = member.Journals.SingleOrDefault(z => z.Id == model.JourId);

            if (journal == null)
            {
                return(JsonError("You can't save a journal that doesn't exist. Or at least, technically you could by creating a new one... but that should have already been done.  If it hasn't already been done then you're working outside the system."));
            }

            journal.Weight    = model.Weight;
            journal.HeartRate = model.HeartRate;
            journal.Story     = model.Story;
            journal.Encrypted = model.Encrypted;

            dm.SaveChanges();
            model.JourId = journal.Id;
            return(JsonOk(model));
        }
Exemplo n.º 7
0
        public JsonResult GetEntry(string date = "", int id = -1)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(JsonError("You are not authenticated"));
            }

            //JourListDMContainer dm = new JourListDMContainer();
            JournalModel model;

            if (date != string.Empty)
            {
                model = new JournalModel(User.Identity.Name, DateTime.Parse(date));
            }
            else if (id != -1)
            {
                model = new JournalModel(User.Identity.Name, id);
            }
            else
            {
                model = new JournalModel(User.Identity.Name, DateTime.Today);
            }

            return(JsonOk(model));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,ID,Date,Day,Symptoms,Body")] JournalModel journal)
        {
            if (id != journal.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(journal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JournalExists(journal.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(journal));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets a new JournalModel instance based on the Bounded properties.
        /// </summary>
        /// <returns>A new fully populated JournalModel instance.</returns>
        private JournalModel GetJournal()
        {
            int          intAmount      = 0;
            int          intIssue       = 0;
            double       doublePrice    = 0;
            double       doubleDiscount = 0;
            JournalModel journal        = null;

            if (JournalNumericPropertiesValid(out intAmount, ref intIssue, ref doublePrice, ref doubleDiscount) && StringJournalPropertiesValid())
            {
                journal = new JournalModel
                {
                    Name               = Name,
                    Amount             = intAmount,
                    Category           = Category,
                    Price              = doublePrice,
                    PublishDate        = PublishDate.Date,
                    Publisher          = Publisher,
                    DiscountPercentage = doubleDiscount,
                    Issue              = intIssue,
                };
            }

            return(journal);
        }
Exemplo n.º 10
0
 public JournalPageViewModel(int key)
 {
     LoadItemsCommand = new Command(ExecuteLoadNewsCommand);
     db          = new Database();
     Key         = key;
     Journal     = db.GetJournal(key);
     Title       = Journal.Title;
     Description = Journal.Description;
 }
Exemplo n.º 11
0
        [HttpPost]/*, ValidateAntiForgeryToken]*/
        public ActionResult JorunalSave(JournalModel model)
        {
            if (ModelState.IsValid && SortMainObject.CheckUserHasWriteAccess(model.SortMainId))
            {
                model.Save();
            }

            return(null);
        }
Exemplo n.º 12
0
        public async Task <JournalModel> InsertJournal(JournalModel journal)
        {
            var response = await _client.PostAsJsonAsync($"/journal", journal);

            string responseMessage = await response.Content.ReadAsStringAsync();

            JournalModel responseJournal = JsonSerializer.Deserialize <JournalModel>(responseMessage);

            return(responseJournal);
        }
Exemplo n.º 13
0
        public JsonResult Edit(JournalModel form)
        {
            if (ModelState.IsValid)
            {
                db.Entry(form).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json("Result", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 14
0
 public JsonResult Journal([FromBody] ObjId EviId)
 {
     if (System.IO.File.Exists($"Journal\\{EviId.id}.txt"))
     {
         return(Json(JournalModel.PedirJournal(EviId.id)));
     }
     else
     {
         return(ErrorDatos("No existen datos de ese usuario"));
     }
 }
Exemplo n.º 15
0
        //
        // GET: /Entry/

        public ActionResult Index()
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(JsonError("You are not authenticated"));
            }

            JournalModel model = new JournalModel(User.Identity.Name, DateTime.Today);

            return(View(model));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("Name,ID,Date,Day,Symptoms, Body")] JournalModel journal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(journal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(journal));
        }
        public async Task <IActionResult> Create([Bind("Id,Date,Thoughts,Gratitudes,Concerns,Questions")] JournalModel journalModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(journalModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(journalModel));
        }
Exemplo n.º 18
0
 public void InsertOrUpdateJournal(JournalModel journal)
 {
     if (database.Table <JournalModel>().Any(x => x.Id == journal.Id))
     {
         database.Update(journal);
     }
     else
     {
         database.Insert(journal);
     }
 }
Exemplo n.º 19
0
 public ActionResult Add(JournalModel model)
 {
     if (ModelState.IsValid)
     {
         _journalService.AddRecord(model.AddRecord);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Exemplo n.º 20
0
        private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            JournalModel item = (JournalModel)e.SelectedItem;

            if (item == null)
            {
                return;
            }

            Navigation.PushAsync(new JournalPage(item.Id));
            ((ListView)sender).SelectedItem = null;
        }
Exemplo n.º 21
0
        public bool SaveEntity([FromBody] JournalModel obj)
        {
            JournalModel entity = new JournalModel()
            {
                Title       = obj.Title,
                Content     = obj.Content,
                JournalID   = Guid.NewGuid().ToString(),
                JournalDate = DateTime.Now
            };

            return(this.journalRepository.SaveEntity(entity) > 0 ? true:false);
        }
Exemplo n.º 22
0
 public IActionResult SaveJournal([FromBody] JournalModel model)
 {
     //server side validations add in ModelState .AddModelError([field], [message])
     if (ModelState.IsValid)
     {
         var obj = model.ToEntity();
         _service.SaveJournalEntry(obj);
         model = obj.ToModel();
         return(Ok(model));
     }
     return(new BadRequestObjectResult(ModelState));
 }
Exemplo n.º 23
0
        public IHttpActionResult AddBook(JournalModel book)
        {
            IHttpActionResult actionResult = BadRequest();

            if (ModelState.IsValid)
            {
                var addedBook = booksRepository.Add(book);
                actionResult = Ok(addedBook);
            }

            return(actionResult);
        }
Exemplo n.º 24
0
        public bool Delete(JournalModel obj)
        {
            bool         isSuccess = false;
            JournalModel model     = this.context.JournalModels.Find(obj.JournalID);

            if (model != null)
            {
                this.context.JournalModels.Remove(model);
                this.context.SaveChanges();
                isSuccess = true;
            }
            return(isSuccess);
        }
Exemplo n.º 25
0
        public void InsertJournal()
        {
            JournalModel model = new JournalModel()
            {
                JournalID   = Guid.NewGuid().ToString(),
                Title       = "保存测试",
                Content     = "Journal一条记录将保存到数据库",
                JournalDate = DateTime.Now
            };
            JournalRepository repository = new JournalRepository();
            long result = repository.SaveEntity(model);

            Assert.AreEqual(1, result);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Updates journal's amount.
        /// </summary>
        private void UpdateJournalAmount(JournalModel journalModel)
        {
            journalModel.Amount--;
            HttpResponseMessage httpResponseMessage = ConstantsHelper.Post(journalModel, booksApiUrl + "/PutJournal", httpClient);

            Journals.Clear();
            Books.Clear();
            PopulateCollections();

            if (journalModel.Amount <= 0)
            {
                var journalToRemove = Journals.FirstOrDefault(j => j.Amount == 0);
                Journals.Remove(journalToRemove);
            }
        }
Exemplo n.º 27
0
        public bool UpdateEntity(JournalModel obj)
        {
            bool         isSuccess = false;
            JournalModel model     = this.context.JournalModels.Find(obj.JournalID);

            if (model != null)
            {
                model.JournalID   = obj.JournalID;
                model.Title       = obj.Title;
                model.Content     = obj.Content;
                model.JournalDate = obj.JournalDate;
                isSuccess         = true;
            }
            return(isSuccess);
        }
Exemplo n.º 28
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            JournalModel = await _context.JournalModel.FirstOrDefaultAsync(m => m.ID == id);

            if (JournalModel == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 29
0
        public override void FuncPreInitCreateView()
        {
            base.FuncPreInitCreateView();
            var journals = new JournalModel <Journal>().GetData(isBlock: false);

            ViewBag.JournalID = journals.Select(x => new CustomSelectListItem()
            {
                Text = x.JournalName, Value = x.JournalID.ToString()
            }).ToList();
            var journalVolumeType = new JournalVolumeTypeModel <JournalVolumeType>().GetData(isBlock: false);

            ViewBag.JournalVolumeTypeID = journalVolumeType.Select(x => new CustomSelectListItem()
            {
                Text = x.JournalVolumeTypeName, Value = x.JournalVolumeTypeID.ToString()
            }).ToList();
        }
Exemplo n.º 30
0
        public IActionResult Index(JournalFilterParams filterParams)
        {
            ViewBag.JournalFilterParams = filterParams;

            var records = _journalService.GetRecords(filterParams.Date);

            var model = new JournalModel
            {
                Records   = records,
                AddRecord = new AddRecordModel {
                    Date = filterParams.Date
                }
            };

            return(View(model));
        }