예제 #1
0
        public Entities.Queue Insert(Entities.Queue queue)
        {
            if (queue.Verify())
            {
                StringBuilder query = new StringBuilder();

                query.AppendLine("IF NOT EXISTS(SELECT [Id] FROM [Core].[Queue] Q WHERE Q.[Name] = @Name)");
                query.AppendLine("BEGIN");
                query.AppendLine("  INSERT INTO [Core].[Queue]");
                query.AppendLine("  (");
                query.AppendLine("      [Name],");
                query.AppendLine("      [MaxWokers]");
                query.AppendLine("  )");
                query.AppendLine("  VALUES");
                query.AppendLine("  (");
                query.AppendLine("      @Name,");
                query.AppendLine("      @MaxWokers");
                query.AppendLine("  )");
                query.AppendLine("END");
                query.AppendLine("SELECT * FROM [Core].[Queue] Q WHERE Q.[Name] = @Name");

                using (IDbConnection connection = database.CreateConnection())
                {
                    queue = connection.Query<Entities.Queue>(query.ToString(), new
                    {
                        Name = queue.Name,
                        MaxWokers = queue.MaxWokers
                    }).FirstOrDefault();
                }

                return queue;
            }
            return null;
        }
예제 #2
0
        public Entities.Branch Execute(Entities.Branch branch)
        {
            branch.Verify();

            Entities.Branch result  = insertDAL.Execute(branch);

            queueBLL.Insert(new Queue { MaxWokers = 1, Name = result.Name });

            return result;
        }
        public ActionResult Save(Entities.Branch branch)
        {
            try
            {
                branch.Verify();
            }
            catch(FluentValidation.ValidationException e)
            {
                Dictionary<string, bool> errors = new Dictionary<string, bool>();

                foreach (var error in e.Errors)
                {
                    errors.Add(error.PropertyName, true);
                }

                return Json(new { Error = errors });
            }

            insertBLL.Execute(branch);

            return Json(new { Url = Url.Action("Index", "BranchList") });
        }