Пример #1
0
        // Methods
        public ModelResult Update()
        {
            using (var entities = new DB_SWQUALEntities())
            {
                int actorId = SessionUtil.GetUserId();

                using (var transaction = entities.Database.BeginTransaction())
                {
                    if (PlanId.HasValue) // Update
                    {
                        try
                        {
                            plan item = entities.plan.Find(PlanId.Value);
                            item.name = name;
                            item.objective = objective;
                            item.problem = problem;
                            item.steps = steps;
                            item.update_date = DateTime.Now;

                            entities.SaveChanges();

                            transaction.Commit();
                            return new ModelResult() { Success = true };
                        }
                        catch(Exception ex)
                        {
                            transaction.Rollback();

                            return new ModelResult() { DisplayMessage = true, Message = Core.CoreFunction.InnermostException(ex), Success = false };
                        }
                    }
                    else // Insert
                    {
                        try
                        {
                            entities.plan.Add(new plan() {
                                create_date = DateTime.Now,
                                name = name,
                                objective = objective,
                                owner_id = actorId,
                                problem = problem,
                                steps = steps,
                                update_date = update_date
                            });

                            entities.SaveChanges();

                            transaction.Commit();
                            return new ModelResult() { Success = true };
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();

                            return new ModelResult() { DisplayMessage = true, Message = Core.CoreFunction.InnermostException(ex), Success = false };
                        }
                    }
                }
            }
        }
Пример #2
0
        public void Search(PlanSearch condition)
        {
            using (var entities = new DB_SWQUALEntities())
            {
                Items = new _DatatableResponseModel();

                var result = from o in entities.plan
                             select o;

                Items.data = result.ToList().Skip(condition.start).Take(condition.length).Select(MediaItemSelector).Cast<object>().ToList();

                Items.draw = condition.draw;
                Items.recordsFiltered = result.Count();
                Items.recordsTotal = result.Count();
            }
        }
Пример #3
0
        // Methods
        public ModelResult Update()
        {
            using (var entities = new DB_SWQUALEntities())
            {
                int actorId = SessionUtil.GetUserId();

                using (var transaction = entities.Database.BeginTransaction())
                {
                    if (SampleId.HasValue) // Update
                    {
                        try
                        {

                            transaction.Commit();
                            return new ModelResult() { Success = true };
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();

                            return new ModelResult() { DisplayMessage = true, Message = Core.CoreFunction.InnermostException(ex), Success = false };
                        }
                    }
                    else // Insert
                    {
                        try
                        {

                            transaction.Commit();
                            return new ModelResult() { Success = true };
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();

                            return new ModelResult() { DisplayMessage = true, Message = Core.CoreFunction.InnermostException(ex), Success = false };
                        }
                    }
                }
            }
        }