public void InitHistories()
 {
     Applicant     = new ApplicantWeb.Models.Applicant();
     HistoryFields = new HistoryFields(new DateTime(2015, 09, 15), ApplicantClassLibrary.TypeHistory.Interview, "Здорово!!!");
     HistoryCreate = new HistoryCreate(HistoryFields, Applicant.ApplicantId, Applicant);
     History       = new History(HistoryCreate);
     HistoryEdit   = new HistoryEdit(HistoryFields);
 }
Beispiel #2
0
        public IHttpActionResult Post(HistoryCreate history)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateHistoryService();

            if (!service.CreateHistory(history))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Beispiel #3
0
        public bool CreateHistory(HistoryCreate model)
        {
            var entity = new History()
            {
                AnimalID        = model.AnimalID,
                CaretakerID     = model.CaretakerID,
                HistoryCareType = model.HistoryCareType,
                DateOfCareStart = model.DateOfCareStart,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Histories.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #4
0
        public bool CreateHistory(HistoryCreate model)
        {
            var entity =
                new History()
            {
                EventName   = model.EventName,
                EventDate   = model.EventDate,
                Description = model.Description,
                GameId      = model.GameId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Histories.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #5
0
        public ActionResult Create(HistoryCreate model)
        {
            var service = new HistoryService();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (service.CreateHistory(model))
            {
                TempData["SaveResult"] = "Your History Entry was created.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "History Entry could not be created.");
            return(View(model));
        }
Beispiel #6
0
 public ActionResult Create(HistoryCreate historyCreate)
 {
     if (Request.IsAuthenticated)
     {
         try
         {
             if (ModelState.IsValid)
             {
                 db.Histories.Add(new History(historyCreate));
                 db.SaveChanges();
                 return(PartialView("PartialList", db.Applicants.Find(historyCreate.ApplicantId)));
             }
             return(View(historyCreate));
         }
         catch
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(Redirect(Url.Action("Login", "Account")));
     }
 }