Ejemplo n.º 1
0
        public async Task <IHttpActionResult> UpdateWarehouseSection([FromBody] WarehouseSection value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            using (TransactionScope scope = new TransactionScope())
                using (var connection = new SqlConnection(sqlConnectionString))
                {
                    connection.Open();

                    var categoryType = new WarehouseSection()
                    {
                        WarehouseID = value.WarehouseID,
                        Section     = value.Section,
                        SubSection  = value.SubSection,
                        Row         = value.Row,
                        Col         = value.Col,
                        Drawers     = value.Drawers,
                        ID          = value.ID
                    };

                    string updateQuery = @"UPDATE tblSection SET WarehouseID = @WarehouseID,Section=@Section,SubSection = @SubSection, Row= @Row, Col= @Col, Drawers= @Drawers WHERE ID = @ID";

                    var result = connection.Execute(updateQuery, categoryType);
                    scope.Complete();
                    return(Json(new { Message = "Record Updated Successfully" }));
                }
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> AddWarehouseSection([FromBody] WarehouseSection warehouseSection)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var connection = new SqlConnection(sqlConnectionString))
            {
                connection.Open();

                var p = new WarehouseSection
                {
                    WarehouseID = warehouseSection.ID,
                    Row         = warehouseSection.Row,
                    Addedon     = DateTime.Now,
                    Section     = warehouseSection.Section,
                    SubSection  = warehouseSection.SubSection,
                    Col         = warehouseSection.Col,
                    Drawers     = warehouseSection.Drawers
                };
                p.ID = connection.Query <int>(@"insert tblSection(WarehouseID,Row,Addedon,Section,SubSection,Col,Drawers) values (@WarehouseID,@Row,@Addedon,@Section,@SubSection,@Col,@Drawers) select cast(scope_identity() as int)", p).First();

                return(Json(new { Message = "Record Inserted Successfully" }));
            }
        }
Ejemplo n.º 3
0
        public dynamic GetByWarehouseSectionId(int Id)
        {
            var warehouseSection = new WarehouseSection();
            var connection       = new SqlConnection(sqlConnectionString);

            warehouseSection = connection.Query <WarehouseSection>("Select * from tblSection where ID = @Id", new { Id = Id }).FirstOrDefault();
            return(warehouseSection);
        }
Ejemplo n.º 4
0
 public static void SetSection(WarehouseSection section)
 {
     ActiveSection = section;
 }