public ActionResult EditCard()
        {
            if (!(User.Identity.IsAuthenticated && User.Identity.Name == "admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            Guid cardId = Guid.Parse(Request.Form["cardId"]);

            if (Request.Form["edit"] != null)
            {
                WorkCards card = CardsDAL.GetCardById(cardId);
                ViewBag.Card      = card;
                ViewBag.Operation = "Edit";
                return(View("Card"));
            }
            else if (Request.Form["delete"] != null)
            {
                if (cardId != null)
                {
                    CardsDAL.DeleteCard(cardId);
                }
                ViewBag.Delete = "Successfully deleted the card";
            }
            else if (Request.Form["save"] != null)
            {
                CardsDAL.EditCard(Guid.Parse(Request.Form["cardId"]), DateTime.Parse(Request.Form["start"]),
                                  int.Parse(Request.Form["duration"]), Request.Form["comment"]);
                ViewBag.Edit = "Successfully edited the card";
            }
            return(View());
        }
示例#2
0
 public CardViewModel(WorkCards card)
 {
     this.CardId     = card.CardId;
     this.Duration   = card.Duration;
     this.LogComment = card.LogComment;
     this.start      = card.StartTime;
 }
示例#3
0
        /**
         * Delete work card
         */
        public static void DeleteCard(Guid cardId)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            WorkCards           card   = entity.WorkCards.First(el => el.CardId == cardId);

            entity.WorkCards.DeleteObject(card);
            entity.SaveChanges();
        }
示例#4
0
        /**
         * Edit work card
         */
        public static void EditCard(Guid cardId, DateTime start, int duration, string comment)
        {
            TimeTrackerEntities entity = new TimeTrackerEntities();
            WorkCards           card   = entity.WorkCards.First(el => el.CardId == cardId);

            card.StartTime  = start;
            card.Duration   = duration;
            card.LogComment = comment;
            entity.SaveChanges();
        }