コード例 #1
0
 public async Task <MonsterTemplateCommand> InsertMonsterTemplateCommand(MonsterTemplateCommand monsterTemplateCommand)
 {
     //try
     //{
     //    string consString = _configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value;
     //    try
     //    {
     //        using (SqlConnection con = new SqlConnection(consString))
     //        {
     //            using (SqlCommand cmd = new SqlCommand("InsertMonsterTemplateCommands"))
     //            {
     //                cmd.CommandType = CommandType.StoredProcedure;
     //                cmd.Connection = con;
     //                cmd.Parameters.AddWithValue("@Command", monsterTemplateCommand.Command);
     //                cmd.Parameters.AddWithValue("@Name", monsterTemplateCommand.Name);
     //                cmd.Parameters.AddWithValue("@MonsterTemplateId", monsterTemplateCommand.MonsterTemplateId);
     //                cmd.Parameters.AddWithValue("@IsDeleted", monsterTemplateCommand.IsDeleted);
     //                con.Open();
     //                var res= cmd.ExecuteScalar();
     //                int commandId = Convert.ToInt32(res);
     //                monsterTemplateCommand.MonsterTemplateCommandId = commandId;
     //                con.Close();
     //            }
     //        }
     //    }
     //    catch (Exception ex)
     //    {
     //        throw ex;
     //    }
     //    //await _context.MonsterTemplateCommands.AddAsync(new MonsterTemplateCommand() {
     //    //    Command= monsterTemplateCommand.Command,
     //    //    IsDeleted=monsterTemplateCommand.IsDeleted,
     //    //    MonsterTemplateId= monsterTemplateCommand.MonsterTemplateId,
     //    //    Name= monsterTemplateCommand.Name,
     //    //});// _repo.Add(itemMasterCommand);
     //    //await _context.SaveChangesAsync();
     //    return monsterTemplateCommand;
     //    //_context.MonsterTemplateCommands.Add(monsterTemplateCommand);
     //    //_context.SaveChanges();
     //    //return monsterTemplateCommand;
     //}
     //catch (Exception ex)
     //{
     //    return monsterTemplateCommand;
     //    // throw;
     //}
     try
     {
         return(await _repo.Add(monsterTemplateCommand));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
コード例 #2
0
        public async Task <MonsterTemplateCommand> UdateMonsterTemplateCommand(MonsterTemplateCommand monsterTemplateCommand)
        {
            var ac = _context.MonsterTemplateCommands.Find(monsterTemplateCommand.MonsterTemplateCommandId);

            if (ac == null)
            {
                return(monsterTemplateCommand);
            }
            try
            {
                ac.Command = monsterTemplateCommand.Command;
                ac.Name    = monsterTemplateCommand.Name;
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(ac);
        }
コード例 #3
0
 public async Task <MonsterTemplateCommand> InsertMonsterTemplateCommandImport(MonsterTemplateCommand monsterTemplateCommand)
 {
     try
     {
         return(await _repo.Add(monsterTemplateCommand));
     }
     catch (Exception ex)
     {
         throw;
     }
 }