コード例 #1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            WorkingCard wCard = new WorkingCard();
            wCard.Id = id;
            wCard.StartDate = DateTime.Parse(collection["StartDate"]);
            wCard.Description = collection["Description"];
            wCard.WorkingHours = TimeSpan.Parse(collection["WorkingHours"]);

            WorkingCardUtility.UpdateWoringCard(wCard);
            return RedirectToAction("Active", "Users");
        }
コード例 #2
0
        public static void AddCardToDb(int usrId, int taskId, DateTime? startDate, TimeSpan hoursMin, string description, bool isFilled)
        {
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                WorkingCard wCard = new WorkingCard();
                wCard.UserId = usrId;
                wCard.TaskId = taskId;
                wCard.StartDate = DateTime.Parse(startDate.Value.ToString());
                wCard.WorkingHours = hoursMin;
                wCard.Description = description;
                wCard.IsFilled = isFilled;

                context.WorkingCard.Add(wCard);
                context.SaveChanges();
            }
        }
コード例 #3
0
        public static void UpdateWoringCard(WorkingCard wCard)
        {
            using (TimeTrackerDbEntities context = new TimeTrackerDbEntities())
            {
                WorkingCard result = (from card in context.WorkingCard
                                      where card.Id == wCard.Id
                                      select card).FirstOrDefault<WorkingCard>();

                result.StartDate = wCard.StartDate;

                result.WorkingHours = wCard.WorkingHours;

                result.Description = wCard.Description;

                context.SaveChanges();
            }
        }