Esempio n. 1
0
        public async Task <IHttpActionResult> AddFormation([FromBody] FormationList value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            using (var connection = new SqlConnection(sqlConnectionString))
            {
                connection.Open();

                var CommandExist = connection.Query <FormationList>("Select * from Formation where Name = @Name", new { Name = value.Name }).FirstOrDefault();
                if (CommandExist == null)
                {
                    var p = new FormationList
                    {
                        Name         = value.Name,
                        Descripition = value.Descripition,
                        CommandId    = value.CommandId,
                        IsActive     = true,
                        Addedon      = DateTime.Now,
                        UndatedOn    = DateTime.Now
                    };
                    p.Id = connection.Query <int>(@"insert Formation(Name,Descripition,CommandId,IsActive,Addedon,UndatedOn) values (@Name,@Descripition,@CommandId,@IsActive,@Addedon,@UndatedOn) select cast(scope_identity() as int)", p).First();

                    return(Json(new { Message = "Record Inserted Successfully" }));
                }
                else
                {
                    throw new ProcessException("Formation already exists");
                }
            }
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> UpdateFormation([FromBody] FormationList value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            using (TransactionScope scope = new TransactionScope())
                using (var connection = new SqlConnection(sqlConnectionString))
                {
                    connection.Open();

                    var Name         = value.Name;
                    var Descripition = value.Descripition;
                    var UndatedOn    = DateTime.Now;
                    var CommandId    = value.CommandId;
                    var Id           = value.Id;


                    string updateQuery = @"UPDATE Formation SET Name = @Name,Descripition=@Descripition,UndatedOn=@UndatedOn,CommandId=@CommandId WHERE Id = @Id";

                    var result = connection.Execute(updateQuery, new
                    {
                        Name,
                        Descripition,
                        UndatedOn,
                        CommandId,
                        Id
                    });
                    scope.Complete();
                    return(Json(new { Message = "Record Updated Successfully" }));
                }
        }
Esempio n. 3
0
        public dynamic GetByFormationId(int Id)
        {
            var formation  = new FormationList();
            var connection = new SqlConnection(sqlConnectionString);

            formation = connection.Query <FormationList>("Select * from Formation where Id = @Id", new { Id = Id }).FirstOrDefault();
            return(formation);
        }
Esempio n. 4
0
 public Models.Squad.Lineup Convert(Database.Entities.Squad.Lineup source, Models.Squad.Lineup destination, ResolutionContext context)
 {
     return(new Models.Squad.Lineup
     {
         Id = source.Id,
         Formation = new Models.Squad.Formation
         {
             Id = source.FormationId,
             Name = source.Formation.Name,
             ComponentName = FormationList.All().FirstOrDefault(f => f.Name == source.Formation.Name)?.ComponentName
         },
         Players = context.Mapper.Map <List <Models.Squad.PlayerToLineup> >(source.Players),
         Created = source.Created.ToString("yyyy-MM-dd")
     });
 }
Esempio n. 5
0
 public void Init(FormationList formationList, IPlayerHasCharacters currentItem)
 {
     this.formationList = formationList;
     this.currentItem   = currentItem;
     lvName.text        = currentItem.Character.quality + "-LV" + currentItem.level + "-" + currentItem.Character.title;
 }